Title: Closing fs streams early could call close during or before I/O · Issue #2006 · nodejs/node · GitHub
Open Graph Title: Closing fs streams early could call close during or before I/O · Issue #2006 · nodejs/node
X Title: Closing fs streams early could call close during or before I/O · Issue #2006 · nodejs/node
Description: Suppose you fs.createWriteStream, pipe something into it, and then need to close the stream early because of an error somewhere else. var writeStream = fs.createWriteStream(someFile); source.pipe(writeStream); // ...time passes... source...
Open Graph Description: Suppose you fs.createWriteStream, pipe something into it, and then need to close the stream early because of an error somewhere else. var writeStream = fs.createWriteStream(someFile); source.pipe(w...
X Description: Suppose you fs.createWriteStream, pipe something into it, and then need to close the stream early because of an error somewhere else. var writeStream = fs.createWriteStream(someFile); source.pipe(w...
Opengraph URL: https://github.com/nodejs/node/issues/2006
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Closing fs streams early could call close during or before I/O","articleBody":"Suppose you `fs.createWriteStream`, pipe something into it, and then need to close the stream early because of an error somewhere else.\n\n``` javascript\nvar writeStream = fs.createWriteStream(someFile);\nsource.pipe(writeStream);\n\n// ...time passes...\n\nsource.unpipe(writeStream);\nwriteStream.close();\n```\n\nCalling `close` on the write stream in this case could cause `close` to be called on the underlying file descriptor while a write operation is still pending. Or, if more than one worker thread is being used, it's possible for the `close` to happen before the write begins.\n\nSpecifically, `WriteStream.close` does not check whether a `fs.write` operation is pending before calling `fs.close`:\n\nhttps://github.com/nodejs/io.js/blob/41951d45b6df789d7e9cf134f0029b0e791706c4/lib/fs.js#L1770\n\nIt seems like this makes it impossible to safely close a write stream early. I've never seen bad behavior from this in practice though, so maybe I'm misunderstanding something.\n\nAre we instead supposed to call `Writable.end` and should never use `WriteStream.close`?\n","author":{"url":"https://github.com/briangreenery","@type":"Person","name":"briangreenery"},"datePublished":"2015-06-18T02:59:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":25},"url":"https://github.com/2006/node/issues/2006"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1cacb063-421b-318e-cb2f-d4e8f0a9d800 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF74:2C3273:6A27F:8C55F:6A517F60 |
| html-safe-nonce | a97289b5b4d13772ef7e6c88878d92a21d7c90b4b3590ee2937466c4d88ab875 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjc0OjJDMzI3Mzo2QTI3Rjo4QzU1Rjo2QTUxN0Y2MCIsInZpc2l0b3JfaWQiOiI0NzgyMjAyOTIwODg0OTU5NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b1e96b895c4df55e3b513ebcba4c0e5bb3640d43136950db4839830c68e60980 |
| hovercard-subject-tag | issue:89184463 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/2006/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db870bfc3e8276e9399c3da4f97feb5bd97e55b35474b1f2acaa79508c071d8a/nodejs/node/issues/2006 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db870bfc3e8276e9399c3da4f97feb5bd97e55b35474b1f2acaa79508c071d8a/nodejs/node/issues/2006 |
| og:image:alt | Suppose you fs.createWriteStream, pipe something into it, and then need to close the stream early because of an error somewhere else. var writeStream = fs.createWriteStream(someFile); source.pipe(w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | briangreenery |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d01c62704ef24df49056c63892a149b775e1353d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width