Title: util.inspect() throws on prototypes of URL subclasses · Issue #66821 · nodejs/node · GitHub
Open Graph Title: util.inspect() throws on prototypes of URL subclasses · Issue #66821 · nodejs/node
X Title: util.inspect() throws on prototypes of URL subclasses · Issue #66821 · nodejs/node
Description: Version v24.21.0 (also v20.20.2, v22.23.1 and v26.11.1; v18.20.2 is unaffected) Platform Darwin 27.0.0 arm64 Subsystem util What steps will reproduce the bug? class MyURL extends URL {} console.log(MyURL.prototype); The same happens with...
Open Graph Description: Version v24.21.0 (also v20.20.2, v22.23.1 and v26.11.1; v18.20.2 is unaffected) Platform Darwin 27.0.0 arm64 Subsystem util What steps will reproduce the bug? class MyURL extends URL {} console.log...
X Description: Version v24.21.0 (also v20.20.2, v22.23.1 and v26.11.1; v18.20.2 is unaffected) Platform Darwin 27.0.0 arm64 Subsystem util What steps will reproduce the bug? class MyURL extends URL {} console.log...
Opengraph URL: https://github.com/nodejs/node/issues/66821
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"util.inspect() throws on prototypes of URL subclasses","articleBody":"### Version\n\nv24.21.0 (also v20.20.2, v22.23.1 and v26.11.1; v18.20.2 is unaffected)\n\n### Platform\n\n```text\nDarwin 27.0.0 arm64\n```\n\n### Subsystem\n\nutil\n\n### What steps will reproduce the bug?\n\n```js\nclass MyURL extends URL {}\nconsole.log(MyURL.prototype);\n```\n\nThe same happens with `util.inspect(MyURL, { showHidden: true })`, or when inspecting any object that references the class with `showHidden`.\n\n### How often does it reproduce? Is there a required condition?\n\nAlways.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe prototype is printed, as it is for `URL.prototype` and for prototypes of other built-in subclasses.\n\n### What do you see instead?\n\n```text\nTypeError: Receiver must be an instance of class URL\n at get href (node:internal/url:1005:10)\n at isURL (node:internal/util/inspect:208:23)\n at formatRaw (node:internal/util/inspect:1128:16)\n at formatValue (node:internal/util/inspect:930:10)\n at inspect (node:internal/util/inspect:407:10)\n```\n\n### Additional information\n\n`isURL()` in `lib/internal/util/inspect.js`, added in #50853, reads `value.href` before its `instanceof` check:\n\n```js\nfunction isURL(value) {\n internalUrl ??= require('internal/url');\n return typeof value.href === 'string' && value instanceof internalUrl.URL;\n}\n```\n\nA subclass prototype passes `instanceof URL`, but calling the `href` getter on it throws because it has no `#context`. Swapping the order of the checks wouldn't fix it. Since v24, `internal/url` exports `isURLInstance()`, a `#context in value` brand check, which would.\n\nThis came up in happy-dom, whose `URL` subclasses Node's: logging any object that references a happy-dom window with `%o` throws (capricorn86/happy-dom#1938).\n\nWritten by an agent (Claude Code, claude-opus-5.5)\n","author":{"url":"https://github.com/TrevorBurnham","@type":"Person","name":"TrevorBurnham"},"datePublished":"2026-10-18T02:43:05Z","url":"https://github.com/nodejs/node/issues/66821"}
| 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:07bea411-5fac-9662-2ea6-8ed2f736502e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B852:26CE8C:2D3FD25:3BCF65B:6B033CFB |
| html-safe-nonce | 40dc04704cb208266ceedef5d755f1bf0b638c4b627be0acd07031f2d95270fe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODUyOjI2Q0U4QzoyRDNGRDI1OjNCQ0Y2NUI6NkIwMzNDRkIiLCJ2aXNpdG9yX2lkIjoiODIyMTczMjk5NjAzODk5OTI5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 669a8a4b9792fc669e1a1096dde170b166696e915cd289eea477d35a033b4869 |
| hovercard-subject-tag | issue:5905486515 |
| 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/66821/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3b1759e692e3654125c468814b5529568df6e0e28712ab9e02bc8f6aa3b043fc/nodejs/node/issues/66821 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3b1759e692e3654125c468814b5529568df6e0e28712ab9e02bc8f6aa3b043fc/nodejs/node/issues/66821 |
| og:image:alt | Version v24.21.0 (also v20.20.2, v22.23.1 and v26.11.1; v18.20.2 is unaffected) Platform Darwin 27.0.0 arm64 Subsystem util What steps will reproduce the bug? class MyURL extends URL {} console.log... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TrevorBurnham |
| 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