-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EBADF with streams and pipeline #267
Comments
I also don't see how The problem is that I get an UNCATCHABLE EBADF error if the descriptor is already closed and I close it. Especially since it's not possible to tell if the descriptor is already closed (at least I could not find a way). |
detachDescriptor will cause tmp to not try to close the already closed file. |
But it will also mean that I have to close it manually, correct? that may be a valid workaround to my case. |
Create a (short!) repro of the issue? |
There is no such thing as an "uncatchable EBADF" in Node.js as far as I know - the only way that could happen is if someone (either node-tmp or your code) is not propagating the error. |
thats exactly it, I think `node-tmp` is not propagating it correctly, I'll
make a reproducible example
…On Sun, 17 Jan 2021 at 12:29, Benjamin Gruenbaum ***@***.***> wrote:
There is no such thing as an "uncatchable EBADF" in Node.js as far as I
know - the only way that could happen is if someone (either node-tmp or
your code) is not propagating the error.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#267 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABAXP2FPO5DIT4UGUO63WI3S2K3ZNANCNFSM4WCMQP4A>
.
|
So firstly, I apologise... it turns out the problem was caused by the magic handling of file descriptors with streams. const destination = await tmp.fileSync();
const stream = fs.createWriteStream(destination.path, { fd:destination.fd });
const abort = () => {
destination.cleanup();
}
// later on in another function
await ppipeline( // just a promisified pipeline function
source,
async function* (source) {
yield source.read(); // just a random transform function that can break at any time.
},
destination.stream
) So let me just put this down if anyone else has an issue with
I only figured this out when trying to reproduce this because the |
See #260
to address the comments: no you cannot catch the error using
.catch
ortry/catch
that was the point of this answer #260 (comment)
Basically (I realise there is a language barrier) you cannot catch the error, at least nothing I did could.
The text was updated successfully, but these errors were encountered: