Compare commits

...

1 Commits

Author SHA1 Message Date
pfg
04b71cc454 Fix #14791 2024-11-05 18:53:08 -08:00
3 changed files with 47 additions and 3 deletions

View File

@@ -371,9 +371,6 @@ pub const Run = struct {
{
if (this.vm.isWatcherEnabled()) {
var prev_promise = this.vm.pending_internal_promise;
if (prev_promise.status(vm.global.vm()) == .rejected) {
_ = vm.unhandledRejection(this.vm.global, this.vm.pending_internal_promise.result(vm.global.vm()), this.vm.pending_internal_promise.asValue());
}
while (true) {
while (vm.isEventLoopAlive()) {

View File

@@ -0,0 +1,3 @@
console.error("Program Launched.");
// @ts-expect-error
console.error(invalidvariablename);

View File

@@ -0,0 +1,44 @@
import { test, expect } from "bun:test";
import { bunExe } from "harness";
for (const flags of [[], ["--watch"], ["--hot"]]) {
test("bun " + flags.map(f => f + " ").join("") + "prints the error only once", async () => {
const proc = Bun.spawn({
cmd: [bunExe(), ...flags, import.meta.dirname + "/14791.fixture.ts"],
env: {
"NO_COLOR": "1",
},
stdout: "inherit",
stdin: "inherit",
stderr: "pipe",
});
await Bun.sleep(200);
proc.kill();
await proc.exited;
let result = "";
for await (const item of proc.stderr.pipeThrough(new TextDecoderStream())) {
result += item;
}
expect(
result
.replaceAll(/at .+?14791\.fixture\.ts/g, "at 14791.fixture.ts")
.replace(/Bun v.+? \(.+?\)/, "")
.trim(),
).toBe(
`
Program Launched.
1 | console.error("Program Launched.");
2 | // @ts-expect-error
3 | console.error(invalidvariablename);
^
ReferenceError: Can't find variable: invalidvariablename
at 14791.fixture.ts:3:34
at asyncFunctionResume (1:11)
at promiseReactionJobWithoutPromiseUnwrapAsyncContext (1:11)
at promiseReactionJob (1:11)
`.trim(),
);
});
}
declare let TextDecoderStream: any;