GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: warn against streaming from character devices by gireeshpunathil · Pull Request #21212 · nodejs/node

Conversation

@gireeshpunathil

@gireeshpunathil gireeshpunathil commented Jun 8, 2018

Copy link
Copy Markdown
Member

charcter device streaming works just like any other streams, but hangs
on the close callsite due to the worker thread being blocked on the read
and main thread waiting for any async event that may not occur.

Document this behavior and suggest a potential workaround.

Fixes: #15439

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to Node.js documentation. fs Issues and PRs related to file-system APIs and the fs module. labels Jun 8, 2018
@jasnell
jasnell requested a review from mafintosh June 9, 2018 01:00
Trott
Trott reviewed Jun 9, 2018
View reviewed changes
Comment thread doc/api/fs.md Outdated

@Trott Trott Jun 9, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: end-less -> endless

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gireeshpunathil gireeshpunathil Jun 11, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, ptal

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Trott

Trott commented Jun 9, 2018

Copy link
Copy Markdown
Member

@nodejs/fs @nodejs/documentation

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vsemozhetbyt
vsemozhetbyt reviewed Jun 9, 2018
View reviewed changes
Comment thread doc/api/fs.md Outdated

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gireeshpunathil gireeshpunathil Jun 11, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vsemozhetbyt - split it for more clarity, ptal.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Trott Trott Aug 13, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"fd" should be in backticks, I think. (Can go either way, but for consistency with the previous paragraph, for example.)

You can probably drop Also note that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jasnell
jasnell approved these changes Jun 10, 2018
View reviewed changes
Trott
Trott previously requested changes Jun 10, 2018
View reviewed changes

@Trott Trott left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just putting a 'request changes' here to make sure this doesn't land without @vsemozhetbyt's comment being addressed. If the comment gets addressed, feel free to dismiss this review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gireeshpunathil
gireeshpunathil force-pushed the char-device-block-behavior branch from 15a20ac to d0aa7ed Compare June 11, 2018 07:22
vsemozhetbyt
vsemozhetbyt approved these changes Jun 11, 2018
View reviewed changes

@vsemozhetbyt vsemozhetbyt left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With nits)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/fs.md Outdated

@vsemozhetbyt vsemozhetbyt Jun 11, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream.close() -> `stream.close()`?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/fs.md Outdated

@vsemozhetbyt vsemozhetbyt Jun 11, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream.close() -> `stream.close()`?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gireeshpunathil
gireeshpunathil force-pushed the char-device-block-behavior branch from 2448d2d to 040f3d5 Compare June 12, 2018 05:47
@gireeshpunathil

gireeshpunathil commented Jun 12, 2018

Copy link
Copy Markdown
Member Author

@vsemozhetbyt - thanks, nits addressed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mafintosh
mafintosh reviewed Jun 12, 2018
View reviewed changes
Comment thread doc/api/fs.md Outdated

@mafintosh mafintosh Jun 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think "epitomize" is a word most non-english speakers will know.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gireeshpunathil gireeshpunathil Jun 12, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please suggest alternative, if you know.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mafintosh mafintosh Jun 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just endless streams straight up? i don't personally know what epitomize mean

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gireeshpunathil gireeshpunathil Jun 12, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the wording from epitomize to exemplifies

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mafintosh
mafintosh reviewed Jun 12, 2018
View reviewed changes
Comment thread doc/api/fs.md Outdated

@mafintosh mafintosh Jun 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow this last sentence.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gireeshpunathil gireeshpunathil Jun 12, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem with character device when abstracted as streams in Node is that they operate on a blocking file descriptor, managed by pooled worker threads, with a passback async handle to the main thread. so once they engage in reading, there is no way to unblock the thread, other than passing a dummy character to 'unblock' the reader thread, close the libuv handles and disengage from further reading.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mafintosh mafintosh Jun 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that something you can do with the fs api here? An example might work to reduce confusion :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gireeshpunathil gireeshpunathil Jun 12, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added an example

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gireeshpunathil
gireeshpunathil force-pushed the char-device-block-behavior branch from f48adc2 to f1f4dfc Compare June 12, 2018 15:27
vsemozhetbyt
vsemozhetbyt reviewed Jun 12, 2018
View reviewed changes
Comment thread doc/api/fs.md Outdated

@vsemozhetbyt vsemozhetbyt Jun 12, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it seems we usually start comments with an uppercase letter and end them with a period.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@gireeshpunathil gireeshpunathil Jun 13, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vsemozhetbyt reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@gireeshpunathil
gireeshpunathil force-pushed the char-device-block-behavior branch from 58c22ab to fc01bd8 Compare June 13, 2018 08:26
@gireeshpunathil gireeshpunathil mentioned this pull request Jun 14, 2018
readline with /dev/tty: echos and doesn't close #21319
Closed
@gireeshpunathil
gireeshpunathil dismissed Trott’s stale review June 22, 2018 10:33

reason for this change request was addressed, hence dismissing

@gireeshpunathil

gireeshpunathil commented Jun 22, 2018

Copy link
Copy Markdown
Member Author

@mafintosh @Trott - all comments were addressed, PTAL. thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Aug 12, 2018

Copy link
Copy Markdown
Member

ping @mafintosh @Trott

gireeshpunathil reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

trivikr
trivikr approved these changes Aug 12, 2018
View reviewed changes
Trott
Trott reviewed Aug 13, 2018
View reviewed changes
Comment thread doc/api/fs.md Outdated

@Trott Trott Aug 13, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit call?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Trott
Trott reviewed Aug 13, 2018
View reviewed changes
Comment thread doc/api/fs.md Outdated

@Trott Trott Aug 13, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue -> and issue or issuing?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Trott

Trott commented Aug 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Left some non-blocking nits. I'm fine with this landing, but am not leaving an approval because the behavior described is not something I'm familiar with. I trust that it is being accurately described, though.

gireeshpunathil reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gireeshpunathil added 2 commits August 14, 2018 12:47
@gireeshpunathil
doc: warn against streaming from character devices
4dfe0b3
charcter device streaming works just like any other streams, but hangs
on the close callsite due to the worker thread being blocked on the read
and main thread waiting for any async event that may not occur.

Document this behavior and suggest a potential workaround.

Fixes: nodejs#15439
@gireeshpunathil
address review comments
9226e41
@gireeshpunathil
gireeshpunathil force-pushed the char-device-block-behavior branch from fc01bd8 to 9226e41 Compare August 14, 2018 07:21
@gireeshpunathil

gireeshpunathil commented Aug 14, 2018

Copy link
Copy Markdown
Member Author

thanks @Trott , I have addressed all your comments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gireeshpunathil

gireeshpunathil commented Aug 28, 2018

Copy link
Copy Markdown
Member Author

landed as 66e6d78

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gireeshpunathil gireeshpunathil closed this Aug 28, 2018
gireeshpunathil added a commit that referenced this pull request Aug 28, 2018
@gireeshpunathil
doc: warn against streaming from character devices
66e6d78
charcter device streaming works just like any other streams, but hangs
on the close callsite due to the worker thread being blocked on the read
and main thread waiting for any async event that may not occur.

Document this behavior and suggest a potential workaround.

Fixes: #15439
PR-URL: #21212

Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
addaleax added a commit to addaleax/node that referenced this pull request Aug 28, 2018
@addaleax
doc: fix up warning text about character devices
56578ba
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: nodejs#21212
@addaleax addaleax mentioned this pull request Aug 28, 2018
doc: fix up warning text about character devices #22569
Closed
3 tasks done
addaleax pushed a commit that referenced this pull request Aug 28, 2018
@gireeshpunathil @addaleax
doc: warn against streaming from character devices
c6ec036
charcter device streaming works just like any other streams, but hangs
on the close callsite due to the worker thread being blocked on the read
and main thread waiting for any async event that may not occur.

Document this behavior and suggest a potential workaround.

Fixes: #15439
PR-URL: #21212

Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
addaleax added a commit that referenced this pull request Aug 31, 2018
@addaleax
doc: fix up warning text about character devices
f2338ed
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
addaleax added a commit that referenced this pull request Aug 31, 2018
@addaleax
doc: fix up warning text about character devices
09f733e
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Sep 3, 2018
@gireeshpunathil @targos
doc: warn against streaming from character devices
5e7c651
charcter device streaming works just like any other streams, but hangs
on the close callsite due to the worker thread being blocked on the read
and main thread waiting for any async event that may not occur.

Document this behavior and suggest a potential workaround.

Fixes: #15439
PR-URL: #21212

Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Sep 3, 2018
@addaleax @targos
doc: fix up warning text about character devices
bfdb28e
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@targos targos mentioned this pull request Sep 5, 2018
Release proposal: v10.10.0 #22716
Merged
targos pushed a commit that referenced this pull request Sep 6, 2018
@gireeshpunathil @targos
doc: warn against streaming from character devices
8ec5a07
charcter device streaming works just like any other streams, but hangs
on the close callsite due to the worker thread being blocked on the read
and main thread waiting for any async event that may not occur.

Document this behavior and suggest a potential workaround.

Fixes: #15439
PR-URL: #21212

Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Sep 6, 2018
@addaleax @targos
doc: fix up warning text about character devices
2a83628
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
This was referenced Sep 6, 2018
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-android-nodejs#236
Closed
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-nodejs#221
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Trott Trott Trott left review comments
@jasnell jasnell jasnell approved these changes
@trivikr trivikr trivikr approved these changes
+2 more reviewers
@mafintosh mafintosh mafintosh left review comments
@vsemozhetbyt vsemozhetbyt vsemozhetbyt approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

doc Issues and PRs related to Node.js documentation. fs Issues and PRs related to file-system APIs and the fs module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Cannot properly close/cleanup character device ReadStream (process hangs)

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@gireeshpunathil @Trott @jasnell @mafintosh @vsemozhetbyt @trivikr @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.