-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Race condition in test #238
Comments
@LinusU - are we seeing this still? (just trying to figure out whether we should keep it opened or not) |
@gireeshpunathil Definitely still seeing it. I've noticed it a fair amount in Node.js's ecosystem-testing utility CITGM. For example: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2040/nodes=ubuntu1604-64/testReport/junit/(root)/citgm/multer_v1_4_2/ I also just reproduced it locally on macOS Mojave by adding mocha's Line 51 in 5937690
...to be: it.only('should process empty fields and an empty file', function (done) { ...and then ran $ while true; do
> node node_modules/.bin/mocha
> if [[ "$?" -ne 0 ]]; then
> break
> fi
> done ...and the failure seems to come up every twenty or thirty runs or so: 1) Disk Storage should process empty fields and an empty file:
Uncaught Error: ENOENT: no such file or directory, stat '/var/folders/7w/pzd4440x60d3gkc3cv7rj8lc0000gp/T/2MR49F8/a25a4ece9ac48e4fc21b525cd7edadd2'
at Object.statSync (fs.js:926:3)
at Object.fileSize (test/_util.js:11:13)
at test/disk-storage.js:80:25
at Immediate.<anonymous> (test/_util.js:32:37)
at processImmediate (internal/timers.js:441:21) |
Changing: Line 42 in 5937690
...to: outStream.on('close', function () { ...makes it so I can't reproduce the test failure anymore. |
Change listened-for event on the output stream in storage/disk.js from 'finish' to 'close' to improve reliability. With 'finish', there is a race condition such that sometimes the callback runs before the file exists. Refs: expressjs#238
This comment has been minimized.
This comment has been minimized.
Probably bug in Node. Proposed PR in core nodejs/node#29930. |
'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
'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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
'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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
The referenced fix in Node core has landed, this should be tested again and determined if it's fixed for multer. |
I haven't noticed the CITGM failure mentioned in #238 (comment) in a long time so I'd guess that any Node.js part of this is fixed on the master branch at least. |
so closing as resolved; we can always re-open if necessary. |
This seems to be very very rare, found it on Travis today.
The text was updated successfully, but these errors were encountered: