Title: Expose the "enhanced" stack trace from uncaught exceptions to the `uncaughtException` and `uncaughtExceptionMonitor` handlers on `process` · Issue #55838 · nodejs/node · GitHub
Open Graph Title: Expose the "enhanced" stack trace from uncaught exceptions to the `uncaughtException` and `uncaughtExceptionMonitor` handlers on `process` · Issue #55838 · nodejs/node
X Title: Expose the "enhanced" stack trace from uncaught exceptions to the `uncaughtException` and `uncaughtExceptionMonitor` handlers on `process` · Issue #55838 · nodejs/node
Description: What is the problem this feature will solve? In my app, I have a logging system which writes entries to files and/or the network in a machine-parsable form. I use the uncaughtException handler on process in order to get uncaught exceptio...
Open Graph Description: What is the problem this feature will solve? In my app, I have a logging system which writes entries to files and/or the network in a machine-parsable form. I use the uncaughtException handler on p...
X Description: What is the problem this feature will solve? In my app, I have a logging system which writes entries to files and/or the network in a machine-parsable form. I use the uncaughtException handler on p...
Opengraph URL: https://github.com/nodejs/node/issues/55838
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Expose the \"enhanced\" stack trace from uncaught exceptions to the `uncaughtException` and `uncaughtExceptionMonitor` handlers on `process`","articleBody":"### What is the problem this feature will solve?\r\n\r\nIn my app, I have a logging system which writes entries to files and/or the network in a machine-parsable form. I use the `uncaughtException` handler on `process` in order to get uncaught exceptions written out to this logging system. I noticed that if there's no `uncaughtException` handler, Node will print out an extra stack trace to the console indicating the call site of the `\u003cemitter>.emit('error', ...)` call which emitted the ultimately-uncaught exception. However, it seems like there's no programmatic way for me to get that extra trace in my own handler.\r\n\r\nThis feature will solve the problem of being able to programmatically extract this extra — and quite useful! — information in a way that works well with a system that eschews the console.\r\n\r\n\r\n### What is the feature you are proposing to solve the problem?\r\n\r\nI don't know what tactic would work best within the larger Node ecosystem, but as a straw-man suggestion:\r\n\r\nAdd a third argument to the `uncaughtException` and `uncaughtExceptionMonitor` callbacks when an \"enhanced\" error is available, containing information corresponding to the site and target of the `emit()` call. It could, for example, be a plain object containing an `Error` representing the call site and an object reference to the emitter itself. But if that's too dangerous, it might instead have strings representing that info. For example (in the former case), the following would nearly duplicate what the current default `uncaughtException` handler prints out to the console:\r\n\r\n```js\r\nprocess.on('uncaughtException', (err, origin, emitInfo) => {\r\n console.log('%s', err.stack);\r\n if (emitInfo) {\r\n const { emitter, emitSite } = emitInfo;\r\n console.log(`Emitted 'error' event of ${emitter.constructor.name} instance at:\\n%s`,\r\n emitSite.stack);\r\n }\r\n});\r\n```\r\n\r\n\r\n### What alternatives have you considered?\r\n\r\nHaving a separate process to scrape console output to find things that look like uncaught exceptions, so I can push them into the structured logging system. (Oof.)","author":{"url":"https://github.com/danfuzz","@type":"Person","name":"danfuzz"},"datePublished":"2024-11-13T18:37:12Z","url":"https://github.com/nodejs/node/issues/55838"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:4683a675-a811-1b0e-c6af-fb9d6e7f9378 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9046:1C7D35:AEB864:E879A6:6AED3502 |
| html-safe-nonce | 3635cb896f16b98b074f1a49008404caa2fa7f30073dde5d48b6e19d7bfe7000 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDQ2OjFDN0QzNTpBRUI4NjQ6RTg3OUE2OjZBRUQzNTAyIiwidmlzaXRvcl9pZCI6IjY2NTU3NjkyNzExNjc5NTYyMjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 743891251056ce67e3fb9a630beb93b757a931a027142712b582bc4073c559b6 |
| hovercard-subject-tag | issue:2656412202 |
| 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/55838/issue_layout |
| twitter:image | https://opengraph.githubassets.com/24c326e2a460830ead21ebdcda011a67c4378133c175e79815fa9f73f34cc93e/nodejs/node/issues/55838 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/24c326e2a460830ead21ebdcda011a67c4378133c175e79815fa9f73f34cc93e/nodejs/node/issues/55838 |
| og:image:alt | What is the problem this feature will solve? In my app, I have a logging system which writes entries to files and/or the network in a machine-parsable form. I use the uncaughtException handler on p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danfuzz |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| 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 | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width