-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1244907
commit d05070d
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { bunEnv, bunExe } from "harness"; | ||
import path from "path"; | ||
|
||
test("stdin destroy after exit crash", async () => { | ||
let before; | ||
await (async () => { | ||
const child = Bun.spawn({ | ||
cmd: [bunExe(), path.join(import.meta.dir, "bad-fixture.js")], | ||
env: bunEnv, | ||
stdout: "pipe", | ||
stdin: "pipe", | ||
}); | ||
|
||
await Bun.sleep(80); | ||
await child.stdin.write("dylan\n"); | ||
await child.stdin.write("999\n"); | ||
await child.stdin.flush(); | ||
await child.stdin.end(); | ||
|
||
async function read() { | ||
var out = ""; | ||
for await (const chunk of child.stdout) { | ||
out += new TextDecoder().decode(chunk); | ||
} | ||
return out; | ||
} | ||
|
||
// This bug manifested as child.exited rejecting with an error code of "TODO" | ||
const [out, exited] = await Promise.all([read(), child.exited]); | ||
|
||
expect(out).toBe(""); | ||
expect(exited).toBe(1); | ||
|
||
Bun.gc(true); | ||
await Bun.sleep(50); | ||
})(); | ||
Bun.gc(true); | ||
}); |