-
-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
Hi,
I have a test which downloads a file with supertest and the file is served by setting the response body to read stream:
ctx.body = fs.createReadStream(filePath);Then after the test finishes, I have a hook where I reset the memfs volume:
afterEach(() => {
vol.reset();
});It looks like when the stream is being destroyed, it asynchronously calls the method to close the file, but the volume is already reset at that point, and it throws the error:
Error: EBADF: bad file descriptor, close
at createError ((...)/node_modules/memfs/lib/volume.js:121:17)
at Volume.getFileByFdOrThrow ((...)/node_modules/memfs/lib/volume.js:650:19)
at Volume.closeSync ((...)/node_modules/memfs/lib/volume.js:878:25)
at Immediate._onImmediate ((...)/node_modules/memfs/lib/volume.js:682:39)
at processImmediate (internal/timers.js:456:21)
Can it be avoided somehow in this case, by adding a check somewhere along those lines if the volume was reset in the meantime? Or do you maybe have any suggestion for me to work around it?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels