Title: assert.deepStrictEqual() and the `vm` module are incompatible · Issue #44462 · nodejs/node · GitHub
Open Graph Title: assert.deepStrictEqual() and the `vm` module are incompatible · Issue #44462 · nodejs/node
X Title: assert.deepStrictEqual() and the `vm` module are incompatible · Issue #44462 · nodejs/node
Description: Version v18.8.0 Platform Linux DESKTOP-TBGODF1 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? import vm from 'node:vm'; import as...
Open Graph Description: Version v18.8.0 Platform Linux DESKTOP-TBGODF1 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the ...
X Description: Version v18.8.0 Platform Linux DESKTOP-TBGODF1 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the ...
Opengraph URL: https://github.com/nodejs/node/issues/44462
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"assert.deepStrictEqual() and the `vm` module are incompatible","articleBody":"### Version\r\n\r\nv18.8.0\r\n\r\n### Platform\r\n\r\nLinux DESKTOP-TBGODF1 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux\r\n\r\n### Subsystem\r\n\r\n_No response_\r\n\r\n### What steps will reproduce the bug?\r\n\r\n```javascript\r\nimport vm from 'node:vm';\r\nimport assert from 'node:assert/strict';\r\nconst g = {exports: {}};\r\nconst result = vm.runInNewContext(`exports.result = {foo:'bar'};`, g);\r\nassert.deepStrictEqual(g.exports.result, {foo: 'bar'});\r\n```\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\n_No response_\r\n\r\n### What is the expected behavior?\r\n\r\nThese two objects are structurally identical and have the `Object` prototype. The `assert` library should accept them as deep-equal.\r\n\r\n### What do you see instead?\r\n\r\nSince the VM script's context creates its own `Object` for use in prototypes, therefore the prototype check introduced to the `assert` library in 02b66b5b866bd8398e7d815d3715ba3f94a5cf65 (#24974, ref #24917) fails since they're not equal (even though they represent the same underlying 'facility' in Javascript).\r\n\r\nThis caused some confusing output:\r\n\r\n```\r\nAssertionError [ERR_ASSERTION]: Values have same structure but are not reference-equal:\r\n\r\n{\r\n foo: 'bar'\r\n}\r\n```\r\n\r\nFurther, of course they're not reference equal - that would defeat the entire purpose of a `deepEqual` check, would it not? 🙃 I had to google to figure out it was referring to prototype checking. Perhaps the error message could be improved here?\r\n\r\n### Additional information\r\n\r\nIt'd be great if we could get a variant of the `node:assert` library that is 1) strict and 2) ignores prototypes for cases like this. I don't see how this could be fixed otherwise, given how v8's contexts work.","author":{"url":"https://github.com/Qix-","@type":"Person","name":"Qix-"},"datePublished":"2022-08-31T01:41:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/44462/node/issues/44462"}
| 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:bfe8b214-1a6d-1fd2-5d7e-eab71a54863e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E24:2A5CAA:15708A5:1F19294:6A4CE3F9 |
| html-safe-nonce | 58e7b1ef9a5ff4de3285dfc2801a7a9748afc217647c0c4c3ff818559c4c7238 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTI0OjJBNUNBQToxNTcwOEE1OjFGMTkyOTQ6NkE0Q0UzRjkiLCJ2aXNpdG9yX2lkIjoiNjU3Mjg1NTA4NjQyMTk1OTY3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9d4456d09bef817b33629794a74fd8c9e83e3bf13230f5e8d18d8e89205f3d9b |
| hovercard-subject-tag | issue:1356624522 |
| 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/44462/issue_layout |
| twitter:image | https://opengraph.githubassets.com/67f23bb953d3fb6769d0288ae913b55a17d4156265a69add69de4c44aebd3e70/nodejs/node/issues/44462 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/67f23bb953d3fb6769d0288ae913b55a17d4156265a69add69de4c44aebd3e70/nodejs/node/issues/44462 |
| og:image:alt | Version v18.8.0 Platform Linux DESKTOP-TBGODF1 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Qix- |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| 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 | c5a57f04eeb310f57c73fd6d751d957e2ca27ed2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width