diff --git a/src/bun_js.zig b/src/bun_js.zig index ef0cebd4f5..565bf3e8d5 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -339,23 +339,19 @@ pub const Run = struct { Output.prettyErrorln("Error occurred loading entry point: {s}", .{@errorName(err)}); Output.flush(); } + // TODO: Do a event loop tick when we figure out how to watch the file that wasn't found + // under hot reload mode + vm.exit_handler.exit_code = 1; + vm.onExit(); + if (run.any_unhandled) { + bun.JSC.SavedSourceMap.MissingSourceMapNoteInfo.print(); - if (vm.hot_reload != .none) { - vm.eventLoop().tick(); - vm.eventLoop().tickPossiblyForever(); - } else { - vm.exit_handler.exit_code = 1; - vm.onExit(); - if (run.any_unhandled) { - bun.JSC.SavedSourceMap.MissingSourceMapNoteInfo.print(); - - Output.prettyErrorln( - "\n{s}", - .{Global.unhandled_error_bun_version_string}, - ); - } - vm.globalExit(); + Output.prettyErrorln( + "\n{s}", + .{Global.unhandled_error_bun_version_string}, + ); } + vm.globalExit(); } // don't run the GC if we don't actually need to diff --git a/test/cli/hot/hot.test.ts b/test/cli/hot/hot.test.ts index b819cdff2f..9b53bb733c 100644 --- a/test/cli/hot/hot.test.ts +++ b/test/cli/hot/hot.test.ts @@ -17,6 +17,21 @@ beforeEach(() => { cwd = hotPath; }); +it("preload not found should exit with code 1 and not time out", async () => { + const root = hotRunnerRoot; + const runner = spawn({ + cmd: [bunExe(), "--preload=/dev/foobarbarbar", "--hot", root], + env: bunEnv, + stdout: "inherit", + stderr: "pipe", + stdin: "ignore", + }); + await runner.exited; + expect(runner.signalCode).toBe(null); + expect(runner.exitCode).toBe(1); + expect(await new Response(runner.stderr).text()).toContain("preload not found"); +}); + it( "should hot reload when file is overwritten", async () => {