Repository navigation
Conversation
|
Updated 1:13 AM PT - Oct 24th, 2026
❌ @robobun, your commit b198368 has 1 failures in
🧪 To try this PR locally: bunx bun-pr 46683That installs a local version of the PR into your bun-46683 --bun |
|
Status Reproduced with the two new tests in Local runs with the debug build on Linux x64: CI. The diff is green. The two red jobs are not from this change:
PR: #46683 |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Return native import promises src/runtime/bake/hmr-module.ts, test/bake/dev/esm.test.ts |
The fallback returns the native import promise. Server and client tests check promise results and resolved values. The server test also checks rejection for a missing import and expected responses from consecutive route requests. |
Possibly related PRs
- oven-sh/bun#46615: Changes the same HMR module-loading runtime, including CommonJS import loading and retry behavior after failed loads.
Suggested reviewers: alii, jarred-sumner
Priority:
Merge Risk: 
Minimal · up to b1983
-
Merge Risk: ⚪ Minimal · up to
b1983The fallback now returns the import promise, and no merge-blocking concern remains from the supplied evidence.
Pre-merge checks: 
4
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline finding, I also checked for sibling sites sharing the missing-return pattern: the new Function import helper at src/runtime/bake/hmr-module.ts:165 is the only one in the runtime, both printer lowerings (src/js_printer/lib.rs:3029 and :3652) call the same dynamicImport method, and hmr-module.ts is the single source for the client and server runtime builds, so no parallel copy needs the same fix. The (await builtin) === path namespace-identity assertion and the client-side base-URL difference for the options form were also examined and ruled out as defects in this change.
Extended reasoning...
The change adds return to the new Function body that forwards import(specifier, opts) in the Bake dev-server HMR runtime and adds two devTest cases covering the server and client runtimes. It touches no security-sensitive surface. One confirmed inline finding (synchronous throw instead of rejection for bundled modules in the error state) was reported separately, so this note only records the sibling-site and ruled-out checks.
Problem
import(x, options)returnsundefinedwhen the dev server did not bundlex(a built-in such asnode:path, a computed specifier).await import(missingFile, { with })intry/catchdoes not reach thecatch, and the unhandled rejection ends the dev server process.HMRModule.dynamicImport(src/runtime/bake/hmr-module.ts:165). The fallback for the options form isnew Function("specifier, opts", "import(specifier, opts)"), and that body has noreturn.Fix
return import(specifier, opts).import(id)without options, already returns its promise.test/bake/dev/esm.test.ts(server runtime and client runtime) fail on main and pass here. The other 18 tests of that file pass.Background
import(x)tohmr.dynamicImport(id, opts). A module that it bundled comes from its own registry. Any other id goes to the engine'simport().import(a, b)is built withnew Functionon first use, because Firefox does not parse it. Anew Functionbody gives a value only throughreturn.Downsides
hmr.dynamicImport(...)lowering is the only caller. The runtime text grows 7 bytes per side (client 52,885 to 52,892, server 10,908 to 10,915).Notes
Runtime size is from
bun src/codegen/bake-codegen.ts --debug=OFFon main and on this branch.Fail-before on main (
bun bd test test/bake/dev/esm.test.tswith main'ssrc/): the server test reportsbuiltin: [false, false],computed: [false, null]andmissing: "resolved". The client test reportscomputed: ["undefined", null].Not in this PR. The same method has two more faults: it evaluates a bundled module inside the
import()call, and a failed load throws at the call and does not reject. A fix for those makesimport()reject, and a caller that keeps the promise (for examplepreloadModuleof react-server-dom-bun, orReact.lazy) then keeps the rejection after the file is fixed, becausereplaceModulesdoes not run that importer again. That work needs the importer re-run first (#46764), so it is separate from this one-token fix. It is #46770.no test proof · iteration 0 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/bake/dev/esm.test.ts