Title: Undocumented Readline 'error' events. · Issue #61037 · nodejs/node · GitHub
Open Graph Title: Undocumented Readline 'error' events. · Issue #61037 · nodejs/node
X Title: Undocumented Readline 'error' events. · Issue #61037 · nodejs/node
Description: Affected URL(s) https://nodejs.org/api/readline.html#class-interfaceconstructor Description of the problem The linked document page does not include any information about 'error' events being emitted by a readline interface. As seen in #...
Open Graph Description: Affected URL(s) https://nodejs.org/api/readline.html#class-interfaceconstructor Description of the problem The linked document page does not include any information about 'error' events being emitt...
X Description: Affected URL(s) https://nodejs.org/api/readline.html#class-interfaceconstructor Description of the problem The linked document page does not include any information about 'error' events bei...
Opengraph URL: https://github.com/nodejs/node/issues/61037
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Undocumented Readline 'error' events.","articleBody":"### Affected URL(s)\n\nhttps://nodejs.org/api/readline.html#class-interfaceconstructor\n\n### Description of the problem\n\nThe linked document page does not include any information about 'error' events being emitted by a readline interface. As seen in https://github.com/nodejs/node/issues/58289, this leads to the conclusion that the only way to see such errors is to attach a handler to the input read stream.\n\nThis does not seem to be correct as of Node 16, however. It seems the behavior was changed but the docs were not updated. Using the following example in Node \u003e= 16.0.0:\n\n```js\nimport {createReadStream} from \"node:fs\";\nimport readLine from \"node:readline\";\n\nlet position = 0;\nconst fakeFs = {\n read: (fd, buffer, offset, len, pos, cb) =\u003e {\n if (position \u003c 10) {\n buffer.write(\"A\\n\");\n position += 2;\n cb(null, 2, buffer);\n } else {\n cb(new Error(\"Some read error\"));\n }\n },\n close: (fd, cb) =\u003e {\n cb();\n },\n open: (name, flags, mode, cb) =\u003e {\n cb(undefined, 42);\n },\n};\n\nconst readStream = createReadStream(\"foo\", { fs: fakeFs });\n\nreadStream.on(\"error\", (err) =\u003e {\n console.log(`Error on read stream: ${err.message}`);\n});\n\nconst lineReader = readLine.createInterface({\n input: readStream,\n crlfDelay: Infinity,\n});\n\nlineReader.on(\"line\", (line) =\u003e {\n console.log(line);\n});\n\nlineReader.on(\"error\", (err) =\u003e {\n console.log(`Error on line reader: ${err.message}`);\n});\n```\n\nOutputs:\n```\nA\nA\nA\nA\nA\nError on read stream: Some read error\nError on line reader: Some read error\n```\n\nIf you omit the error event handler on the line reader interface you get unhandled error event warnings, which is how I noticed this to begin with:\n\n```\nA\nA\nA\nA\nA\nError on read stream: Some read error\nnode:events:342\n throw er; // Unhandled 'error' event\n ^\n\nError: Some read error\n at Object.read (file:///home/sripberger/node-being-stupid/index.js:12:16)\n at ReadStream._read (node:internal/fs/streams:246:6)\n at ReadStream.Readable.read (node:internal/streams/readable:487:10)\n at flow (node:internal/streams/readable:1009:34)\n at resume_ (node:internal/streams/readable:990:3)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)\nEmitted 'error' event on Interface instance at:\n at ReadStream.onerror (node:readline:248:10)\n at ReadStream.emit (node:events:377:35)\n at emitErrorNT (node:internal/streams/destroy:193:8)\n at emitErrorCloseNT (node:internal/streams/destroy:158:3)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)\n```\n\nI have verified this same behavior in all the LTS releases from 16 on. I'd say it's more convenient this way, but perhaps the docs should be updated to reflect.\n\nHere's some system other system info in case it is desired:\n\n```\nOperating System:\n──────────────────────────────────────────────────────────────────────────────────────────\nPlatform : linux\nDistro : Debian GNU/Linux\nRelease : 13\nCodename : trixie\nKernel : 6.6.87.2-microsoft-standard-WSL2\nArch : x64\n```","author":{"url":"https://github.com/sripberger-tc","@type":"Person","name":"sripberger-tc"},"datePublished":"2025-12-12T20:13:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/61037/node/issues/61037"}
| 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:aa7928d4-0c08-822c-ced0-fa6a02a133f1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC48:340E06:5624F:7093F:6A4C0FBD |
| html-safe-nonce | 55852344bebbb87a5ad747797acf21cd5fa415db3867cb21995710e65246c20f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzQ4OjM0MEUwNjo1NjI0Rjo3MDkzRjo2QTRDMEZCRCIsInZpc2l0b3JfaWQiOiIxNTY2MzYxNzM2OTc3MzIxOTE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 94fd66d0644a71ea5a2db5e2b63714cb396c0d35e99cded3d00882509c1b2648 |
| hovercard-subject-tag | issue:3724706202 |
| 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/61037/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dda80605be0b83f8af0626fe45926c66eeaeefb2efadc7169cd2519f2a390cc3/nodejs/node/issues/61037 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dda80605be0b83f8af0626fe45926c66eeaeefb2efadc7169cd2519f2a390cc3/nodejs/node/issues/61037 |
| og:image:alt | Affected URL(s) https://nodejs.org/api/readline.html#class-interfaceconstructor Description of the problem The linked document page does not include any information about 'error' events being emitt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sripberger-tc |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0ccfc9e5281bfe12e38a4d632dc422843e4d5b6757917f7efda2f6567d72fea9 |
| 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 | 18812876666a23a0912556e224383baa4c84cf8e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width