Title: vm: Error.prepareStackTrace behaves inconsistently across versions · Issue #21270 · nodejs/node · GitHub
Open Graph Title: vm: Error.prepareStackTrace behaves inconsistently across versions · Issue #21270 · nodejs/node
X Title: vm: Error.prepareStackTrace behaves inconsistently across versions · Issue #21270 · nodejs/node
Description: Version: 8.11.2 Platform: Linux 4.16.4-1-ARCH Subsystem: vm In Node 6.x (tested on v6.14.2), the following results in the prepareStackTrace defined inside the context being used: const { runInNewContext } = require('vm'); console.log(run...
Open Graph Description: Version: 8.11.2 Platform: Linux 4.16.4-1-ARCH Subsystem: vm In Node 6.x (tested on v6.14.2), the following results in the prepareStackTrace defined inside the context being used: const { runInNewCo...
X Description: Version: 8.11.2 Platform: Linux 4.16.4-1-ARCH Subsystem: vm In Node 6.x (tested on v6.14.2), the following results in the prepareStackTrace defined inside the context being used: const { runInNewCo...
Opengraph URL: https://github.com/nodejs/node/issues/21270
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"vm: Error.prepareStackTrace behaves inconsistently across versions","articleBody":"* **Version**: 8.11.2\r\n* **Platform**: Linux 4.16.4-1-ARCH\r\n* **Subsystem**: vm\r\n\r\nIn Node 6.x (tested on v6.14.2), the following results in the `prepareStackTrace` defined inside the context being used:\r\n\r\n```js\r\nconst { runInNewContext } = require('vm');\r\nconsole.log(runInNewContext(`() => {\r\n Error.prepareStackTrace = () => 'hello';\r\n return new Error();\r\n}`)().stack);\r\n```\r\nThe stack is logged as `hello`.\r\n\r\nIn Node 8.x (tested with 8.11.2), it will just output a normal stack, ignoring the `prepareStackTrace` defined in the context.\r\n\r\nIt seems that in Node 8, the `prepareStackTrace` from the currently running context (i.e. the one where `.stack` is called) is used, whereas in Node 6, the one where the Error was instantiated is used.\r\n\r\nNote that this only happens when the Error is passed along, and *not* when it's a thrown exception. I suspect that's because when it's thrown, `DecorateErrorStack` is run, which gets the stack before it's passed to the main context:\r\n\r\nhttps://github.com/nodejs/node/blob/faf417ba12024a24906fbeb38edeec78256a1c09/src/node_contextify.cc#L735-L747\r\n\r\nNote also that when the stack is retrieved inside the new context, the in-context `prepareStackTrace` is always used, regardless of version.\r\n\r\n","author":{"url":"https://github.com/bengl","@type":"Person","name":"bengl"},"datePublished":"2018-06-11T21:14:00Z","url":"https://github.com/nodejs/node/issues/21270"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:aad7a61b-eb62-3768-486c-b667a3ec7a5d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B1C:C397B:31F61C:3FC9B7:6B03436E |
| html-safe-nonce | d41ded3cb07a82e51e5eb55f1ec974dc6753f9d9b2f1a88056baea5decc910ba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjFDOkMzOTdCOjMxRjYxQzozRkM5Qjc6NkIwMzQzNkUiLCJ2aXNpdG9yX2lkIjoiNzE4ODA5MTk3MTcxNjcyNzY2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a8756a5cd06bf0d576d94c4555f0de712b69c3524afff6e77a008cc998219f87 |
| hovercard-subject-tag | issue:331352697 |
| 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/21270/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f92b0ce951dba441b8441680e6d718b78c35dfd6664b11df698c519029e62e12/nodejs/node/issues/21270 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f92b0ce951dba441b8441680e6d718b78c35dfd6664b11df698c519029e62e12/nodejs/node/issues/21270 |
| og:image:alt | Version: 8.11.2 Platform: Linux 4.16.4-1-ARCH Subsystem: vm In Node 6.x (tested on v6.14.2), the following results in the prepareStackTrace defined inside the context being used: const { runInNewCo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bengl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width