diff options
| author | 2022-11-27 19:37:14 -0800 | |
|---|---|---|
| committer | 2022-11-27 19:37:14 -0800 | |
| commit | 002f4ecc9e0dfb19ea9e5032b812b9b976706995 (patch) | |
| tree | 34fae197918c8064d456a855b987c0b8bd36dc03 /test/bun.js/spawn-streaming-stdout.test.ts | |
| parent | 495f25501f7bcfddec6e91cca7815cc6220fb53e (diff) | |
| download | bun-002f4ecc9e0dfb19ea9e5032b812b9b976706995.tar.gz bun-002f4ecc9e0dfb19ea9e5032b812b9b976706995.tar.zst bun-002f4ecc9e0dfb19ea9e5032b812b9b976706995.zip | |
Fix crash in console.log
Diffstat (limited to '')
| -rw-r--r-- | test/bun.js/spawn-streaming-stdout.test.ts | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/test/bun.js/spawn-streaming-stdout.test.ts b/test/bun.js/spawn-streaming-stdout.test.ts index 1f736533a..1d19fe5da 100644 --- a/test/bun.js/spawn-streaming-stdout.test.ts +++ b/test/bun.js/spawn-streaming-stdout.test.ts @@ -5,37 +5,32 @@ import { gcTick } from "gc"; test("spawn can read from stdout multiple chunks", async () => { gcTick(true); - var exited; - await (async function () { - const proc = spawn({ - cmd: [bunExe(), import.meta.dir + "/spawn-streaming-stdout-repro.js"], - stdout: "pipe", - env: { - BUN_DEBUG_QUIET_LOGS: 1, - }, - }); - exited = proc.exited; - gcTick(true); - var counter = 0; - try { - for await (var chunk of proc.stdout) { - gcTick(true); - expect(new TextDecoder().decode(chunk)).toBe("Wrote to stdout\n"); - counter++; - if (counter > 3) break; - } - } catch (e) { - console.log(e.stack); - throw e; - } - gcTick(true); + for (let i = 0; i < 10; i++) + await (async function () { + var exited; + const proc = spawn({ + cmd: [bunExe(), import.meta.dir + "/spawn-streaming-stdout-repro.js"], + stdout: "pipe", + stderr: "ignore", + env: { + BUN_DEBUG_QUIET_LOGS: 1, + }, + }); + exited = proc.exited; + let counter = 0; + try { + for await (var chunk of proc.stdout) { + expect(new TextDecoder().decode(chunk)).toBe("Wrote to stdout\n"); + counter++; - expect(counter).toBe(4); - gcTick(); - proc.kill(); - gcTick(); - })(); - await exited; - gcTick(true); + if (counter > 3) break; + } + } catch (e) { + console.log(e.stack); + throw e; + } + expect(counter).toBe(4); + await exited; + })(); }); |
