Title: fs writeFile after truncate doesn't write at beginning of the file · Issue #24923 · nodejs/node · GitHub
Open Graph Title: fs writeFile after truncate doesn't write at beginning of the file · Issue #24923 · nodejs/node
X Title: fs writeFile after truncate doesn't write at beginning of the file · Issue #24923 · nodejs/node
Description: Version: v11.3.0 Platform: Win 10 Test case: var fs = require('fs').promises; async function bug() { await fs.writeFile('test', '012345678901234567890123456789'); const fd = await fs.open('test', 'r+'); await fd.readFile({ encoding: 'utf...
Open Graph Description: Version: v11.3.0 Platform: Win 10 Test case: var fs = require('fs').promises; async function bug() { await fs.writeFile('test', '012345678901234567890123456789'); const fd = await fs.open('test', '...
X Description: Version: v11.3.0 Platform: Win 10 Test case: var fs = require('fs').promises; async function bug() { await fs.writeFile('test', '012345678901234567890123456789'); const fd =...
Opengraph URL: https://github.com/nodejs/node/issues/24923
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fs writeFile after truncate doesn't write at beginning of the file","articleBody":"* **Version**: v11.3.0\r\n* **Platform**: Win 10\r\n\r\nTest case:\r\n\r\n```javascript\r\nvar fs = require('fs').promises;\r\n\r\nasync function bug() {\r\n await fs.writeFile('test', '012345678901234567890123456789');\r\n const fd = await fs.open('test', 'r+');\r\n await fd.readFile({ encoding: 'utf8' });\r\n await fd.truncate(0);\r\n await fd.writeFile('Extra data not at beginning');\r\n await fd.close();\r\n}\r\n\r\nbug();\r\n```\r\n\r\nThis will result a file with lots of '\\0' at beginning of the file.\r\n\r\nAnd w/o the ability to seek, there is no way to write at the beginning of the file.","author":{"url":"https://github.com/kghost","@type":"Person","name":"kghost"},"datePublished":"2018-12-09T17:51:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/24923/node/issues/24923"}
| 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:8e5e9af0-10b2-d53e-221c-91f3ada82ffb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AADC:22EFAB:463B17:658FE2:6A4E06BB |
| html-safe-nonce | 6d66c43e6cb0c89ca2d021d436244f14ff9c72a87cb22d2df79807bac2d35ed4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQURDOjIyRUZBQjo0NjNCMTc6NjU4RkUyOjZBNEUwNkJCIiwidmlzaXRvcl9pZCI6IjEzODkyMTA1MjM3NDkxODkzMDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2abb399b35d574d3bf919af23037a4875c3606d23ecbaaf8ce58172eafb2c842 |
| hovercard-subject-tag | issue:389046631 |
| 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/24923/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c8b9af3d8144ed55bd08df8939333fb7817731ef05f5debd275979ac4f38b0b1/nodejs/node/issues/24923 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c8b9af3d8144ed55bd08df8939333fb7817731ef05f5debd275979ac4f38b0b1/nodejs/node/issues/24923 |
| og:image:alt | Version: v11.3.0 Platform: Win 10 Test case: var fs = require('fs').promises; async function bug() { await fs.writeFile('test', '012345678901234567890123456789'); const fd = await fs.open('test', '... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kghost |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| 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 | 52bde38e24398476f8eb1e0760c81346c6a00812 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width