Repository navigation
fix(node): use /bundle as cwd when evaluating dynamically imported modules - #8797
Jeremiah-D wants to merge 2 commits into
Conversation
…dules Signed-off-by: Jeremiah-D <235112616+Jeremiah-D@users.noreply.github.com>
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
This pull request was not reviewed automatically because its author does not have write access to this repository. A maintainer with write access can start a review by commenting |
|
Hi @Jeremiah-D, thanks for the PR. Could you please sign the CLA so we can land it? |
The wd-test embeds process-cwd-lazy.js, but the file was not listed in the wd_test data attribute, so all three test variants failed in CI with: Couldn't read file for embed: process-cwd-lazy.js Signed-off-by: Jeremiah-D <235112616+Jeremiah-D@users.noreply.github.com>
|
Thanks for taking a look! One thing I found while checking CI: the three On the CLA: noted — that's on my side to sign, I'll get it done so this can land. |
Fixes #8786.
With the new module registry, the top level of a dynamically imported module saw process.cwd() return
/instead of/bundle, and chdir() threw EPERM, so relative reads failed on//.... The eval callback in the new module registry suppresses the IoContext before evaluating, and nothing provided a TmpDirStoreScope, so getCurrentWorkingDirectory() had nothing to read. The legacy dynamic import path and the top-level bootstrap both declare a scope for exactly this reason, so this does the same in the callback — only when none is current yet, since the bootstrap already provides one while the main module is evaluated and the scope asserts against nesting. Temporary files created during evaluation are discarded with the scope, matching top-level behavior.Added a regression test: a lazily imported module asserts cwd is /bundle at its top level, chdirs to /tmp and back, and reads a sibling bundle module by relative path. I could not run the wd-test locally (no bazel in this environment), so that part relies on CI.