Skip to content

fs: do not emit 'finish' before 'open' on writing empty file - #29930

Closed
ronag wants to merge 1 commit into
nodejs:masterfrom
nxtedition:fs-fix-write-stream-open-final
Closed

fs: do not emit 'finish' before 'open' on writing empty file#29930
ronag wants to merge 1 commit into
nodejs:masterfrom
nxtedition:fs-fix-write-stream-open-final

Conversation

@ronag

@ronagronag commented Oct 11, 2019

Copy link
Copy Markdown
Member

'finish' could previously be emitted before the file has been
created when ending a write stream without having written any
data.

Refs: expressjs/multer#238

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

@nodejs-github-botnodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Oct 11, 2019
@ronag
ronagforce-pushed the fs-fix-write-stream-open-final branch from 936bd44 to c0ba9a2CompareOctober 11, 2019 10:19
@ronag

Copy link
Copy Markdown
MemberAuthor

@Trott@mcollina

@mcollina

Copy link
Copy Markdown
Member

The commit has the wrong subsystem prefix. It’s not stream, but rather fs.

@Trott

Copy link
Copy Markdown
Member

@nodejs/fs

@TrottTrott changed the title stream: don't emit 'finish' before 'open' on write empty filefs: do not emit 'finish' before 'open' on writing empty fileOct 11, 2019
@Trott

Copy link
Copy Markdown
Member

The commit has the wrong subsystem prefix. It’s not stream, but rather fs.

I tried to amend the commit message but don't have permission to the nxtedition/node.git repo. But I did change the title of this PR to what I would recommend the commit message be changed to.

@TrottTrott left a comment

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.

LGTM with commit messages/subsytem changed to fs (and assuming no CI surprises).

Will run CITGM too to make sure this fixes the multer issue and doesn't unexpectedly create issues somewhere else.

@nodejs-github-bot

This comment has been minimized.

@Trott

Copy link
Copy Markdown
Member

@TrottTrott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 11, 2019
'finish' could previously be emitted before the file has been
created when ending a write stream without having written any
data.
Refs: expressjs/multer#238
@ronag
ronagforce-pushed the fs-fix-write-stream-open-final branch from c0ba9a2 to f341a47CompareOctober 11, 2019 13:54
@ronag

Copy link
Copy Markdown
MemberAuthor

amended commit msg

@mcollinamcollina left a comment

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.

LGTM

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@TrottTrott added this to the 13.0.0 milestone Oct 11, 2019
@Trott

Copy link
Copy Markdown
Member

CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2049/

CITGM results look great. No multer failures anymore and no new unexpected failures.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

nodejs-github-bot commented Oct 12, 2019

Copy link
Copy Markdown
Collaborator

Trott pushed a commit that referenced this pull request Oct 13, 2019
'finish' could previously be emitted before the file has been
created when ending a write stream without having written any
data.
Refs: expressjs/multer#238
PR-URL: #29930
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@Trott

Copy link
Copy Markdown
Member

Landed in ba45367. Thanks!

@TrottTrott closed this Oct 13, 2019
targos pushed a commit that referenced this pull request Oct 18, 2019
'finish' could previously be emitted before the file has been
created when ending a write stream without having written any
data.
Refs: expressjs/multer#238
PR-URL: #29930
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@boneskull

Copy link
Copy Markdown
Member

It looks like this may be causing some test failures in userland: see sindresorhus/copy-file#38

https://travis-ci.org/sindresorhus/cp-file/jobs/602461047#L280

In this case, errno is undefined whereas before it was -5.

@boneskull

Copy link
Copy Markdown
Member

previously the first error emitted from the fs readable stream was EIO; now it's ERR_STREAM_WRITE_AFTER_END. going to guess that's because the latter now comes out of "open" and the former out of "finish"

given this test is doing some monkeypatching in its harness, we can probably just work around that, but wanted to make sure this was intended?

@ronag

Copy link
Copy Markdown
MemberAuthor

@boneskull: I'm not sure I'm following. Can you provide a simple example?

@boneskull

Copy link
Copy Markdown
Member

@ronag I can't really, as it's not my code and I don't really understand the intent. But I can tell you that previous to Node.js v12.13.0, the first error emitted from a writable stream in this test case was one w/ codeEIO; and now it's one with ERR_STREAM_WRITE_AFTER_END.

https://github.com/sindresorhus/cp-file/blob/master/test/async.js#L244

@mcollina

Copy link
Copy Markdown
Member

@boneskull would you mind opening a new issue in this repo? Would you mind confirming that Node 12.12.0 was working as expected.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.fsIssues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@ronag@mcollina@Trott@nodejs-github-bot@boneskull@addaleax@Fishrock123@lpinca