ReviewOS

home-lang/home

fix(runtime): hot-reload sourcemap remapping and preload-not-found message

#767
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Parent: #66

On the unchanged test/cli/hot, pinned Bun 4982b91e37 passes 15/15 while Home passes 10/15. The two --watch cases were fixed in 2b48dc0 (#759); these five remain and reproduce identically on the parent of that commit, so they are pre-existing and unrelated to it:

  • preload not found should exit with code 1 and not time out — Home's message is error: loading '<path>': ModuleNotFound; the test expects upstream's preload-not-found text.
  • should work with sourcemap generation
  • should not remap against a stale sourcemap after a partial-file reload
  • should work with sourcemap loading
  • should work with sourcemap loading with large files

The four sourcemap cases all compare a stack trace's mapped positions after a hot reload, so they likely share one cause in the reload-time sourcemap remapping rather than four separate ones. test/cli/hot had no recorded Home result before this batch (it is one of the 60 unrecorded directories reported in https://github.com/home-lang/home/issues/66#issuecomment-5781051825).

9 days ago

Fixed on main by ce5d0c0996d5f971a270f85f6a96722c0bb355a3.

The Home-owned VmRunState now follows pinned Bun when the initial entrypoint rejects under --hot: it registers the main file, waits for watcher activity, and permits a corrected file to recover the process. Entrypoint load failures now print the VM resolver log, preserving preload not found, and standalone module graphs now lazily load/cache embedded sourcemaps for stack remapping.

Validation on the exact pushed source:

  • required ReleaseFast JSC build: 50/50 steps succeeded
  • unchanged test/cli/hot: 15/15 tests pass across hot.test.ts, watch.test.ts, and watch-many-dirs.test.ts
  • unchanged compiled-standalone sourcemap regression: 1/1 passes
  • combined gate: 16 pass, 0 fail, 489 assertions
  • Zig formatting and diff checks pass
  • no corpus tests, fixtures, assertions, deadlines, skips, TODOs, snapshots, or expected outcomes changed
9 days ago

Fixed on origin/main by c6ab9aeeb. Verified on a fresh Darwin arm64 JSC debug build of that tree: unchanged test/cli/hot is 15 pass / 0 fail, identical to pinned Bun 4982b91e37.

passfail
Home at 2b48dc083 (before)105
Home at c6ab9aeeb150
pinned Bun 4982b91e37150

Worth recording, because the issue title pointed at the wrong subsystem: the four sourcemap cases were not a sourcemap-remapping bug. Each drives 50 error/reload cycles, and the child never survived the first one — a rejected entry point exited whenever the rejection was unhandled, even with a reloader attached. Measured with a driver that replays the test's cycle against both engines, pinned Bun produced 1002:11, 1002:13, 1002:15 … across cycles (the expected 1 + "throw new ".length + counter*2 columns) while Home's stderr ended after the first error. Once the entry stays on the watcher, all four pass with the columns already correct — the remapping was never wrong.

The fifth case, preload not found, was the second half: a loadEntryPoint error printed one generic line and discarded the VM log, which is where preload not found "<path>" is written.

I had reached the same two-part fix independently (identical vm.hot_reload != .none or handled branch); c6ab9aeeb landed first and its error-path message matches upstream's text more closely, so I dropped mine rather than duplicating it.

Sign in to comment on this issue.