Skip to content
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

Automatically wait for file streams to open #82

Closed
jamestalmage opened this issue Mar 29, 2017 · 12 comments
Closed

Automatically wait for file streams to open #82

jamestalmage opened this issue Mar 29, 2017 · 12 comments

Comments

@jamestalmage
Copy link
Contributor

It might be possible to wait for the open event on file streams (if we can find a way to detect that a stream is in fact a file stream, and that it will indeed eventually open).

See the discussion here

@sindresorhus
Copy link
Owner

We could detect the follow custom properties attached to it:

  path: 'ad',
  fd: null,
  flags: 'w',
  mode: 438,

Maybe we should add isStream.fsWritable() and isStream.fsReadable() methods to is-stream?

@jamestalmage
Copy link
Contributor Author

I just made is-file-stream. https://github.com/jamestalmage/is-file-stream

@sindresorhus
Copy link
Owner

Even better. Less bloat for is-stream. The module looks good.

@SamVerschueren
Copy link
Contributor

This is a great idea. Makes working with file streams much easier. I will have a look at implementing this.

@sindresorhus
Copy link
Owner

I think we should also at least try to get this into Node.js core by opening an issue argumenting it's the expected behavior.

@SamVerschueren
Copy link
Contributor

Good point. We probably all know how this will end but at least we can try.

@sindresorhus
Copy link
Owner

sindresorhus commented Mar 30, 2017

At least we can then reference Node.js' unwillingness to good UX. It's always worth trying to improve core Node.js if possible, as it benefits of lot more users, and of course less code for us to maintain.

@SamVerschueren
Copy link
Contributor

Totally agree with that.

@jamestalmage
Copy link
Contributor Author

jamestalmage commented Mar 30, 2017

Basically, they only allow streams that have file descriptors, and under the hood, they convert streams to those file descriptors.

It would have been way less confusing for them not to allow streams, and just provide a findUnderlyingFileDescriptor(stream).

Streams passed to child_process.spawn are handled completely differently than anywhere else in Node-land. Not having the magical "convenience" of this automatic unwrapping would have ultimately been so much less confusing.

@sindresorhus sindresorhus changed the title Automatically wait for file streams to open. Automatically wait for file streams to open Jun 9, 2017
@ehmicky
Copy link
Collaborator

ehmicky commented Dec 18, 2023

Should this be closed in favor for #617?

(Also relevant: #616)

@sindresorhus
Copy link
Owner

Yup

@ehmicky
Copy link
Collaborator

ehmicky commented May 8, 2024

This feature has been just fixed in Execa 9.0.0. Please see (and share!) the release post and the changelog.

Please see more information here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants