← Back to Pull requests

fix(node): use /bundle as cwd when evaluating dynamically imported modules #8797

Open
Jeremiah-D opened this pull request with 76 lines diff across 5 files
View on GitHub
Jeremiah-D Jeremiah-D commented on Nov 21, 2026 23:20 UTC
Author

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.

Diff: 76 lines (+67 / -9) across 5 files Reviewer: jasnell Review duration: 8128m
All Vouch review confidence checks passed
Residual risk 0.08 = Change Risk (0.35) × (1 − Review Confidence (0.77)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 76 lines diff across 5 files
0.35
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.69 · 3 substantive comment(s)
0.69
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
76%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.260
Real PR Conversation Timeline
6 items
github-actions[bot] github-actions[bot] commented on Nov 21, 2026 23:21 UTC
Bot

<br/>Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.<br/>
- - -
I have read the CLA Document and I hereby sign the CLA
- - -
<sub>You can retrigger this bot by commenting recheck in this Pull Request. </sub><sub>Posted by the CLA Assistant Lite bot.</sub>

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 21, 2026 23:21 UTC
Reviewer

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

clanky-the-clanker[bot] clanky-the-clanker[bot] commented on Nov 21, 2026 23:22 UTC
Bot

<!-- durable-reviewer:review -->

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 clanky review (or clanker review or @clanky-the-clanker review), optionally followed by instructions (e.g. clanky review focus on the retry logic).

jasnell jasnell approved these changes on Nov 25, 2026 05:17 UTC
Approved Reviewer

Approved these changes.

bartlomieju bartlomieju commented on Nov 26, 2026 16:19 UTC
Contributor

Hi @Jeremiah-D, thanks for the PR. Could you please sign the CLA so we can land it?

Reviewers
Assignees
Jeremiah-D Jeremiah-D
Labels
risk: low confidence: 76.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 34.8% (LOW) · Higher = larger blast radius
34.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 76.5% · Lower = rushed or shallow review
76.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 8.2% · Safe to merge
8.2%