fix(runner): resolve #playwright alias in runtime isolates#1386
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR adds Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
CodeRabbit (@coderabbitai) review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/domains/runtimeEnv/execSubpathImports.test.ts`:
- Around line 88-96: The existing recovery test only covers malformed JSON, so
add a case in execSubpathImports.test.ts that uses a custom Fs mock for
writeExecSubpathImports/readPackageJson where readFile rejects with a non-ENOENT
error on an existing package.json. Exercise the readPackageJson path in
execSubpathImports.ts and assert the behavior after the fix, using the same
helpers like makeExecDir and writeExecSubpathImports to keep the test aligned
with the current setup.
In `@src/domains/runtimeEnv/execSubpathImports.ts`:
- Around line 61-67: `readExistingImports` currently treats arrays as valid
objects, which can let malformed `imports` data merge numeric keys into the
result. Harden the guard in `readExistingImports` so it only returns plain
objects and falls back to `{}` for arrays or any non-plain object. Keep the fix
localized to this helper so `execSubpathImports` continues to merge imports
safely.
- Around line 42-59: `readPackageJson` is treating every `fs.readFile` failure
as a missing file, which can cause `writeExecSubpathImports` to overwrite an
existing `package.json` with only `imports`. Update `readPackageJson` to only
return an empty object for the expected missing-file case (for example, ENOENT)
and rethrow or propagate other I/O errors. Keep the existing JSON parse fallback
for invalid content, and preserve the merge behavior in
`writeExecSubpathImports` so existing fields and pre-existing imports remain
intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4bc99ef5-07d5-4836-b0f1-58019fbddc2f
📒 Files selected for processing (3)
src/domains/runtimeEnv/execSubpathImports.test.tssrc/domains/runtimeEnv/execSubpathImports.tssrc/domains/runtimeEnv/prepareRunDir.ts
|
CodeRabbit (@coderabbitai) review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/domains/runtimeEnv/execSubpathImports.test.ts`:
- Around line 98-111: The test in execSubpathImports.test.ts is asserting a
rejected promise without awaiting or returning it, so the runner may finish
before the assertion settles. Update the writeExecSubpathImports rejection check
in this test to return the expect(...).rejects.toThrow(...) promise from the
async test callback so the failure is properly observed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5735157e-fb65-4b53-a309-739d6de53bcb
📒 Files selected for processing (2)
src/domains/runtimeEnv/execSubpathImports.test.tssrc/domains/runtimeEnv/execSubpathImports.ts
|
CodeRabbit (@coderabbitai) review |
Overview of Changes
Flows in the isolated managed runtime crashed with
ERR_PACKAGE_IMPORT_NOT_DEFINEDbecause the platform's pulled flow bundle strips theimportsfield frompackage.json, so the stagedexec/package.jsonhad no#playwrightalias to resolve. A newwriteExecSubpathImportshelper merges the alias back in after staging, resolving it through the existing inner-hopnode_modulessymlink to the pinnedplaywrightpackage — fixing resolution for both the Node import path and the compiled-binaryBun.buildpath.Before this fix, running a flow that imports from
#playwrightfailed at module resolution:Testing
bun run typecheck bun run lint bun run format:check bun run knip bun run test bun run build#playwrightand run it via the CLI's managed runtime (projectDirset).exec/package.jsonin the staged run dir contains"imports": { "#playwright": "playwright" }alongside the bundle's original fields.ERR_PACKAGE_IMPORT_NOT_DEFINED, in both the Node dev path and a compiled binary build.Checklist