Title: Unhandled Exception in readline interface · Issue #58289 · nodejs/node · GitHub
Open Graph Title: Unhandled Exception in readline interface · Issue #58289 · nodejs/node
X Title: Unhandled Exception in readline interface · Issue #58289 · nodejs/node
Description: Version 24.0.1 Platform Darwin ... 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64 Linux ... 6.8.0-39-generic #39-Ubuntu SMP PREEMPT_DYNAMIC Sat Jul 6 02:50:39 UTC 20...
Open Graph Description: Version 24.0.1 Platform Darwin ... 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64 Linux ... 6.8.0-39-generic #39-Ubuntu SMP P...
X Description: Version 24.0.1 Platform Darwin ... 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64 Linux ... 6.8.0-39-generic #39-Ubuntu SMP P...
Opengraph URL: https://github.com/nodejs/node/issues/58289
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unhandled Exception in readline interface","articleBody":"### Version\n\n24.0.1\n\n### Platform\n\n```text\nDarwin ... 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64\n\nLinux ... 6.8.0-39-generic #39-Ubuntu SMP PREEMPT_DYNAMIC Sat Jul 6 02:50:39 UTC 2024 aarch64 GNU/Linux\n```\n\n### Subsystem\n\nreadline\n\n### What steps will reproduce the bug?\n\nThe following code creates a dummy fs that throws an error on the fs.close() call.\nThis error can be caught with events.once() when using the fs directly.\nWhen using the fs together with readline, the error is not caught by events.once().\n\n```js\nimport { once } from 'events'\nimport { createReadStream } from 'fs'\nimport { createInterface } from 'readline'\n\nlet position = 0\nconst myDummyFilesystem = {\n read: (fd, buffer, offset, len, pos, cb) =\u003e { buffer.write(\"A\\n\"); cb(null, ((position += 2) \u003c= 10) ? 2 : 0, buffer) },\n close: (x, cb) =\u003e { cb(new Error(\"close failed\")) },\n open: (name, flags, mode, cb) =\u003e { cb(undefined, 42) }\n}\n\nasync function bad() {\n const file = createReadStream('app.js', { fs: myDummyFilesystem })\n const rl = createInterface({ input: file })\n let lineNr = 0\n rl.on('line', (line) =\u003e console.log(`bad ${++lineNr} ${line}`))\n await once(rl, 'close') // DOES NOT CATCH Error of the fs.close() CALL\n}\n\nasync function good() {\n const file = createReadStream('app.js', { fs: myDummyFilesystem })\n let lineNr = 0\n file.on('data', (line) =\u003e console.log(`good ..`))\n await once(file, 'close') // CATCHES Error of the fs.close() CALL\n}\n\nawait (good().catch(e =\u003e console.error(\"nice first catch\", e)))\nposition = 0\nbad().catch(e =\u003e console.error(\"nice second catch\", e))\n```\n\n### How often does it reproduce? Is there a required condition?\n\nalways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nthe await once(...) also catches the error on fs.close()\n\n\n### What do you see instead?\n\nUnhandled Exception error\n\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/BenderMarkusKremer","@type":"Person","name":"BenderMarkusKremer"},"datePublished":"2025-05-12T06:01:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/58289/node/issues/58289"}
| 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:dd31d708-b1bc-82c2-cf47-e68b02408067 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 873A:127DAD:770BAB:9E8337:6A4C3ED4 |
| html-safe-nonce | 822d20a1c7ca0e037363531197e1cdf97778badc566c629400ec9278f4f32e0a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzNBOjEyN0RBRDo3NzBCQUI6OUU4MzM3OjZBNEMzRUQ0IiwidmlzaXRvcl9pZCI6IjQzNDI4NjYzMTA2NjY2NjU2ODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d55f26cc469da129e6e180e492c61575db7f697382b8320b0fa1455008700a51 |
| hovercard-subject-tag | issue:3055730468 |
| 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/58289/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dda80605be0b83f8af0626fe45926c66eeaeefb2efadc7169cd2519f2a390cc3/nodejs/node/issues/58289 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dda80605be0b83f8af0626fe45926c66eeaeefb2efadc7169cd2519f2a390cc3/nodejs/node/issues/58289 |
| og:image:alt | Version 24.0.1 Platform Darwin ... 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64 Linux ... 6.8.0-39-generic #39-Ubuntu SMP P... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | BenderMarkusKremer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1b6b16d04026f131a36d57e3b01d0f4d26a51800edf48bf5ed0256e0ac905511 |
| 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 | d11deab54ce15bac57bda991cc63805976812c11 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width