Skip to content

fs: add autoClose option to fs.createWriteStream - #3679

Closed
saquibkhan wants to merge 1 commit into
nodejs:masterfrom
saquibkhan:feature-autoclose
Closed

fs: add autoClose option to fs.createWriteStream#3679
saquibkhan wants to merge 1 commit into
nodejs:masterfrom
saquibkhan:feature-autoclose

Conversation

@saquibkhan

Copy link
Copy Markdown
Contributor

Add support to fs.createWriteStream and fs.WriteStream for an autoClose
option that behaves similarly to the autoClose option supported by
fs.createReadStream and fs.ReadStream.

When an instance of fs.WriteStream created with autoClose === false finishes,
it is not destroyed. Its underlying fd is not closed and it is the
responsibility of the user to close it.

@saquibkhan

Copy link
Copy Markdown
ContributorAuthor

@jasnell@misterdjules As discussed I created a new pull request for autoClose feature. node-v0.x-archive/pull/25275

This PR can be landed on v5/v4/v0.12/v0.10

it would be really nice if i see this PR land :-)

@Fishrock123

Copy link
Copy Markdown
Contributor

cc @nodejs/streams

@Fishrock123Fishrock123 added fs Issues and PRs related to the fs subsystem / file system. stream Issues and PRs related to the stream subsystem. semver-minor PRs that contain new features and should be released in the next minor version. labels Nov 5, 2015

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you use const for imports?

@bnoordhuis

Copy link
Copy Markdown
Member

Basic premise looks alright to me. The checks in the test can be made a little tighter.

@saquibkhan

Copy link
Copy Markdown
ContributorAuthor

@bnoordhuis Done! I updated the review comments given by you.

@jasnell

Copy link
Copy Markdown
Member

Overall this is fine, but as a semver-minor it woud not be able to land in v0.10, v0.12 or v4.x.

Comment threaddoc/api/fs.markdown Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would like to see this reworded a bit to make it absolutely obvious that the default behavior is autoClose = true. Perhaps move the third sentence to the front?

@jasnell

Copy link
Copy Markdown
Member

LGTM with one nit on the docs

@ronkorving

Copy link
Copy Markdown
Contributor

In your PR message, you write When an instance of fs.WriteStream created with autoClose === true finishes,, but I think you mean to say === false?

@saquibkhan

Copy link
Copy Markdown
ContributorAuthor

@jasnell@ronkorving Done! Updated the doc and commit message. Thanks!

@ronkorving

Copy link
Copy Markdown
Contributor

The PR message still says "true" instead of "false", sorry :) Commit message is 👍

@saquibkhan

Copy link
Copy Markdown
ContributorAuthor

@ronkorving Done!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indent errors.

@jasnell

Copy link
Copy Markdown
Member

@saquibkhan ... when you get a chance, please take a look at @bnoordhuis' comments, then please rebase and update :-)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I am using ! to test fd is not null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if you're specifically testing for not null, perhaps assert(stream.fd !== null) would be better

@saquibkhan

Copy link
Copy Markdown
ContributorAuthor

@bnoordhuis@jasnell I have updated the code as per review comments.

@ronkorving

Copy link
Copy Markdown
Contributor

@saquibkhan "This branch has conflicts that must be resolved"

Comment threadlib/fs.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a !! on the last options.autoClose to guarantee we have a Boolean.

@saquibkhan
saquibkhanforce-pushed the feature-autoclose branch 2 times, most recently from 3b9ffce to 3f24d5cCompareDecember 10, 2015 15:36
@saquibkhan

Copy link
Copy Markdown
ContributorAuthor

@cjihrig@ronkorving@jasnell@bnoordhuis Updated the code as per the review comments.. LGTM

@cjihrig

Copy link
Copy Markdown
Contributor

LGTM pending CI

@saquibkhansaquibkhan changed the title fs: add autoClose option to fs.WriteStreamfs: add autoClose option to fs.createWriteStreamDec 11, 2015
Add support to fs.createWriteStream and fs.createWriteStream for an autoClose
option that behaves similarly to the autoClose option supported by
fs.createReadStream and fs.ReadStream.
When an instance of fs.createWriteStream created with autoClose === false finishes,
it is not destroyed. Its underlying fd is not closed and it is the
responsibility of the user to close it.
@saquibkhan

Copy link
Copy Markdown
ContributorAuthor

@ronkorving@jasnell@bnoordhuis@cjihrig Can we merge?

@jasnell

Copy link
Copy Markdown
Member

@jasnell

Copy link
Copy Markdown
Member

unrelated failure in CI

jasnell pushed a commit that referenced this pull request Jan 11, 2016
Add support to fs.createWriteStream and fs.createWriteStream for an autoClose
option that behaves similarly to the autoClose option supported by
fs.createReadStream and fs.ReadStream.
When an instance of fs.createWriteStream created with autoClose === false finishes,
it is not destroyed. Its underlying fd is not closed and it is the
responsibility of the user to close it.
PR-URL: #3679
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@jasnell

Copy link
Copy Markdown
Member

Landed in 6039a7c

@jasnelljasnell closed this Jan 11, 2016
evanlucas pushed a commit that referenced this pull request Jan 18, 2016
Add support to fs.createWriteStream and fs.createWriteStream for an autoClose
option that behaves similarly to the autoClose option supported by
fs.createReadStream and fs.ReadStream.
When an instance of fs.createWriteStream created with autoClose === false finishes,
it is not destroyed. Its underlying fd is not closed and it is the
responsibility of the user to close it.
PR-URL: #3679
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
evanlucas added a commit that referenced this pull request Jan 20, 2016
Notable changes:
* events: make sure console functions exist (Dave) #4479
* fs: add autoClose option to fs.createWriteStream (Saquib) #3679
* http: improves expect header handling (Daniel Sellers) #4501
* node: allow preload modules with -i (Evan Lucas) #4696
* v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) #4463
* Minor performance improvements:
- lib: Use arrow functions instead of bind where possible (Minwoo Jung) #3622
- module: cache stat() results more aggressively (Ben Noordhuis) #4575
- querystring: improve parse() performance (Brian White) #4675
PR-URL: #4742
evanlucas added a commit that referenced this pull request Jan 21, 2016
Notable changes:
* events: make sure console functions exist (Dave) #4479
* fs: add autoClose option to fs.createWriteStream (Saquib) #3679
* http: improves expect header handling (Daniel Sellers) #4501
* node: allow preload modules with -i (Evan Lucas) #4696
* v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) #4463
* Minor performance improvements:
- lib: Use arrow functions instead of bind where possible (Minwoo Jung) #3622
- module: cache stat() results more aggressively (Ben Noordhuis) #4575
- querystring: improve parse() performance (Brian White) #4675
PR-URL: #4742
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
Add support to fs.createWriteStream and fs.createWriteStream for an autoClose
option that behaves similarly to the autoClose option supported by
fs.createReadStream and fs.ReadStream.
When an instance of fs.createWriteStream created with autoClose === false finishes,
it is not destroyed. Its underlying fd is not closed and it is the
responsibility of the user to close it.
PR-URL: nodejs#3679
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
Notable changes:
* events: make sure console functions exist (Dave) nodejs#4479
* fs: add autoClose option to fs.createWriteStream (Saquib) nodejs#3679
* http: improves expect header handling (Daniel Sellers) nodejs#4501
* node: allow preload modules with -i (Evan Lucas) nodejs#4696
* v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) nodejs#4463
* Minor performance improvements:
- lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622
- module: cache stat() results more aggressively (Ben Noordhuis) nodejs#4575
- querystring: improve parse() performance (Brian White) nodejs#4675
PR-URL: nodejs#4742
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fsIssues and PRs related to the fs subsystem / file system.semver-minorPRs that contain new features and should be released in the next minor version.streamIssues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@saquibkhan@Fishrock123@bnoordhuis@jasnell@ronkorving@cjihrig