aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/stream/node-stream.test.js
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-07-30 16:18:13 +0800
committerGravatar GitHub <noreply@github.com> 2023-07-30 01:18:13 -0700
commit413fd281208f24a532c47249dec1bfc3aef2bf37 (patch)
tree824f840e3b1cf637b8a632fac7b1ff04fca1afb9 /test/js/node/stream/node-stream.test.js
parent40a9ba63409694443058f558df2e480a8f16ff54 (diff)
downloadbun-413fd281208f24a532c47249dec1bfc3aef2bf37.tar.gz
bun-413fd281208f24a532c47249dec1bfc3aef2bf37.tar.zst
bun-413fd281208f24a532c47249dec1bfc3aef2bf37.zip
Fix coredump when reading an empty file(`node:stream:createReadStream`) (#3882)
* Fix coredump when reading an empty file. Close: #3607 * It seems that the fd is closed when `auto_close` is true.
Diffstat (limited to 'test/js/node/stream/node-stream.test.js')
-rw-r--r--test/js/node/stream/node-stream.test.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/js/node/stream/node-stream.test.js b/test/js/node/stream/node-stream.test.js
index 51252a5f6..5f5b9d67a 100644
--- a/test/js/node/stream/node-stream.test.js
+++ b/test/js/node/stream/node-stream.test.js
@@ -41,6 +41,32 @@ describe("Readable", () => {
readable.pipe(writable);
});
+ it("should be able to be piped via .pipe, issue #3607", done => {
+ const path = `${tmpdir()}/${Date.now()}.testReadStreamEmptyFile.txt`;
+ writeFileSync(path, "");
+ const stream = createReadStream(path);
+ stream.on("error", err => {
+ done(err);
+ });
+
+ let called = false;
+ const writable = new Writable({
+ write(chunk, encoding, callback) {
+ called = true;
+ callback();
+ },
+ });
+ writable.on("finish", () => {
+ try {
+ expect(called).toBeFalse();
+ } catch (err) {
+ return done(err);
+ }
+ done();
+ });
+
+ stream.pipe(writable);
+ });
it("should be able to be piped via .pipe, issue #3668", done => {
const path = `${tmpdir()}/${Date.now()}.testReadStream.txt`;
writeFileSync(path, "12345");