Title: intent to implement - rework of stack trace decoration · Issue #21958 · nodejs/node · GitHub
Open Graph Title: intent to implement - rework of stack trace decoration · Issue #21958 · nodejs/node
X Title: intent to implement - rework of stack trace decoration · Issue #21958 · nodejs/node
Description: This is an attempt to finally fix the inconsistent stack decoration in node core... hopefully future-facing enough for everyone. the final code might not be js but the logic will look something like this: // Called for every stack trace ...
Open Graph Description: This is an attempt to finally fix the inconsistent stack decoration in node core... hopefully future-facing enough for everyone. the final code might not be js but the logic will look something lik...
X Description: This is an attempt to finally fix the inconsistent stack decoration in node core... hopefully future-facing enough for everyone. the final code might not be js but the logic will look something lik...
Opengraph URL: https://github.com/nodejs/node/issues/21958
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"intent to implement - rework of stack trace decoration","articleBody":"This is an attempt to finally fix the inconsistent stack decoration in node core... hopefully future-facing enough for everyone.\r\n\r\nthe final code might not be js but the logic will look something like this:\r\n\r\n```js\r\n // Called for every stack trace in the isolate.\r\n // more consistency as a platform and no more\r\n // calling decorateErrorStack which\r\n // is super slow and inconsistent.\r\n // Using the V8 callback also means we don't need\r\n // to store the state of whether an exception has\r\n // been decorated, V8 does it for us.\r\n setPrepareStackTraceCallback(\r\n (global, shouldNotDecorate, safeToString, error, frames, message) =\u003e {\r\n\r\n // V8 engine prepareStackTrace polyfill\r\n // To be buffer-constructor-style-deprecated\r\n // if/when ECMA262 error stacks API is finalized.\r\n // Being able to explicitly bail here means we don't\r\n // run into double-decoration issues, like with my last\r\n // attempt to fix stack decoration.\r\n if (global.Error !== undefined \u0026\u0026\r\n typeof global.Error.prepareStackTrace === 'function') {\r\n return global.Error.prepareStackTrace(error, frames);\r\n }\r\n\r\n const errorString = safeToString(error);\r\n\r\n // checks for Symbol.for('node.error.decorate') === false\r\n // or an internal weakset for core things (iirc there were one\r\n // or two places where we disable the arrow so i threw this in)\r\n if (shouldNotDecorate(error)) {\r\n return `${errorString}\\n at ${frames.join('\\n at ')}`;\r\n }\r\n\r\n const [\r\n sourceLine,\r\n resourceName,\r\n lineNumber,\r\n startColumn,\r\n endColumn,\r\n ] = message;\r\n\r\n // same output we have now\r\n return `${resourceName}:${lineNumber}\r\n${sourceLine}\r\n${' '.repeat(startColumn)}${'^'.repeat(endColumn - startColumn)}\r\n${errorString}\r\n at ${frames.join('\\n at ')}`;\r\n});\r\n```\r\n\r\ni have a patch here (https://chromium-review.googlesource.com/c/v8/v8/+/1119768) to implement the API callback in V8 (and after that lands I have another patch lined up to make v8::StackTrace movable to js-land) but before any of that happens V8 wants to know we will actually use this.\r\n\r\nThe only thing not handled here is when node has an uncaught non-error exception: https://github.com/nodejs/node/blob/811598bcdae74ed8460ccb265d9939f36858f75a/src/node.cc#L976-L985 but i think we can still make that work if we really want to (i would argue that we shouldn't)\r\n\r\n/cc @hashseed @schuay @addaleax @Trott","author":{"url":"https://github.com/devsnek","@type":"Person","name":"devsnek"},"datePublished":"2018-07-24T14:13:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":21},"url":"https://github.com/21958/node/issues/21958"}
| 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:f5e4a161-a49b-2aba-92d5-2aae1bfbcd63 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EAB8:38A7FD:11BBD:18596:6A4D9003 |
| html-safe-nonce | df913eb49a522445bec3befc01d579d70f895962f29918e5be41ced44b93445d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUI4OjM4QTdGRDoxMUJCRDoxODU5Njo2QTREOTAwMyIsInZpc2l0b3JfaWQiOiI1MDIyMjU5NDkzMjcxODY3Mzk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c1eec9b6ab1221ba7cacd0b9627b25a7c8ace04452869b170a8a3a2b50a0c20c |
| hovercard-subject-tag | issue:344056462 |
| 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/21958/issue_layout |
| twitter:image | https://opengraph.githubassets.com/23b9ffc8ec6d6319ce076243fbb256d33795e511cc6abe9d22ac0630c02f39e8/nodejs/node/issues/21958 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/23b9ffc8ec6d6319ce076243fbb256d33795e511cc6abe9d22ac0630c02f39e8/nodejs/node/issues/21958 |
| og:image:alt | This is an attempt to finally fix the inconsistent stack decoration in node core... hopefully future-facing enough for everyone. the final code might not be js but the logic will look something lik... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devsnek |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| 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 | 74e2a9c78f1e38588de4f25885878349d721eedf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width