Repository navigation
Conversation
When a runtime plugin's onLoad handler matches an imported file, the normal transpile path that registers the file with the watcher is bypassed — the transpiler never opens the file because the source comes from the plugin. As a result, edits to that file never trigger a reload under --watch or --hot, whether the plugin succeeded or threw. Register the specifier with the watcher in Bun__runVirtualModule whenever a plugin matches (returns a result or throws), for absolute paths in the default/file namespace. Fixes #17270
|
Updated 1:04 AM PT - May 13th, 2026
❌ @robobun, your commit 5efdb23 has 1 failures in
🧪 To try this PR locally: bunx bun-pr 30608That installs a local version of the PR into your bun-30608 --bun |
|
Found 5 issues this PR may fix:
🤖 Generated with Claude Code |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/jsc/ModuleLoader.zig`:
- Around line 1133-1136: Replace the call to std.fs.path.isAbsolute(path) with
the repo convention bun.path.Platform.auto.isAbsolute(path) in the ModuleLoader
logic that checks the path before skipping node_modules; keep
std.fs.path.extension(path) as-is. Update the conditional in the block that
references the local variable path and the jsc_vm/transpiler loader call (the
lines around the use of jsc_vm.transpiler.options.loader and
jsc_vm.bun_watcher.addFileByPathSlow) so it uses
bun.path.Platform.auto.isAbsolute(...) instead of std.fs.path.isAbsolute(...).
In `@test/regression/issue/17270.test.ts`:
- Line 40: Add an explicit 15000ms timeout to the tests that spawn a `bun
--watch` subprocess and call `nextMatching()` to avoid CI flakiness; locate the
test definition for test("after onLoad throws", ...) and the other sibling test
in the same file that also uses `--watch`/`nextMatching()` and pass 15000 as the
timeout argument to the test function (i.e., use the test(name, fn, 15000)
signature) so the watch startup, initial compile, and file-change detection have
enough time.
🪄 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
Run ID: 3ba4d222-7872-44f9-b46c-6c1fce84b517
📒 Files selected for processing (2)
src/jsc/ModuleLoader.zigtest/regression/issue/17270.test.ts
There was a problem hiding this comment.
♻️ Duplicate comments (1)
test/regression/issue/17270.test.ts (1)
42-74:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd explicit timeouts to both watch-process tests.
Line 42 and Line 76 run long-lived
bun --watchsubprocess flows and await multiplenextMatching()transitions; with the default 5000ms timeout these are prone to CI flakes. Please set an explicit timeout (e.g.15_000) on both tests.⏱️ Proposed fix
- test("after onLoad throws", async () => { + test("after onLoad throws", async () => { using dir = tempDir("watch-plugin-throw", { "bunfig.toml": `preload = ["./plugin.js"]\n`, "plugin.js": plugin, "entry.js": `import "./foo.js";\n`, "foo.js": `BAD; console.log("hello v1");\n`, }); @@ proc.kill(); await proc.exited; - }); + }, 15_000); - test("after onLoad succeeds", async () => { + test("after onLoad succeeds", async () => { using dir = tempDir("watch-plugin-ok", { "bunfig.toml": `preload = ["./plugin.js"]\n`, "plugin.js": plugin, "entry.js": `import "./foo.js";\n`, "foo.js": `console.log("hello v1");\n`, }); @@ proc.kill(); await proc.exited; - }); + }, 15_000);Based on learnings: In IPC-related tests that spawn parent/child processes, set explicit test timeouts (e.g., 15000ms) because the default 5000ms is often insufficient.
Also applies to: 76-109
🤖 Prompt for 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. In `@test/regression/issue/17270.test.ts` around lines 42 - 74, Add an explicit 15_000ms timeout to the long-lived watch-process tests so CI flakes stop occurring: update the test() call for "after onLoad throws" (the test that spawns bun with --watch and uses nextMatching/forEachLine) to include a 15000 timeout argument, and do the same for the second watch-test around lines 76-109 (the other test that spawns a watch subprocess). This ensures the async spawn/nextMatching flows have a longer timeout than the default 5000ms.
🤖 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.
Duplicate comments:
In `@test/regression/issue/17270.test.ts`:
- Around line 42-74: Add an explicit 15_000ms timeout to the long-lived
watch-process tests so CI flakes stop occurring: update the test() call for
"after onLoad throws" (the test that spawns bun with --watch and uses
nextMatching/forEachLine) to include a 15000 timeout argument, and do the same
for the second watch-test around lines 76-109 (the other test that spawns a
watch subprocess). This ensures the async spawn/nextMatching flows have a longer
timeout than the default 5000ms.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 20fcebd5-2f25-4aa4-87a0-4c767fabe03d
📒 Files selected for processing (1)
test/regression/issue/17270.test.ts
|
CI status: the diff is green — Remaining red is unrelated flake, all on Windows and none touching the watcher/plugin path:
I've already re-rolled once (5efdb23). Needs a maintainer to retry/merge. |
|
Closing: this PR's implementation lives entirely in Zig source files that have since been removed from the tree as part of the Rust migration. The change can no longer merge cleanly and the files it edits no longer exist on If the underlying issue is still present, it will need a fresh fix against the Rust implementation. |
What does this PR do?
Fixes #17270
Fixes #19496
Fixes #5844
Fixes #4790
Fixes #5431
When a runtime plugin's
onLoadhandler matches an imported file under--watch/--hot, edits to that file never trigger a reload. This happens both when the plugin throws (the reported case — e.g. a transpiler plugin hitting a parse error) and when it succeeds.Repro
bun --watch entry.js # edit foo.js → nothing happensCause
The watcher is populated inside
transpileSourceCodeafter the transpiler opens the source file (input_file_fd). When a plugin'sonLoadmatches,Bun__runVirtualModulereturns the plugin result and the C++ side either rejects immediately (throw case) or callsBun__transpileVirtualModulewith avirtual_source(success case). In both paths the transpiler never opens the real file, soinput_file_fdstays invalid andbun_watcher.addFileis never called.The entry-point file happened to be covered anyway by a separate
addMainToWatcherIfNeededfallback, which masked the bug for single-file repros.Fix
In
Bun__runVirtualModule, whenever a plugin matches (returns a value or throws), register the specifier with the watcher viaaddFileByPathSlow— for absolute paths in the default/filenamespace, skippingnode_modules(same filter the normal path uses). When no plugin matches we fall through to the existing transpile path unchanged.How did you verify your code works?
New regression test
test/regression/issue/17270.test.tscovers:Both tests time out on
mainand pass with this change.Also ran
test/cli/hot/watch.test.ts,test/cli/watch/watch.test.ts, andtest/js/bun/plugin/plugins.test.ts— all green.