René's URL Explorer Experiment


Title: [Bug] assert.strictEqual OOM on objects with deeply shared references · Issue #61346 · nodejs/node · GitHub

Open Graph Title: [Bug] assert.strictEqual OOM on objects with deeply shared references · Issue #61346 · nodejs/node

X Title: [Bug] assert.strictEqual OOM on objects with deeply shared references · Issue #61346 · nodejs/node

Description: Version v25.2.1 Platform Darwin Hafezs-MacBook-Pro.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000 arm64 Subsystem assert What steps will reproduce the bug? // Run with:...

Open Graph Description: Version v25.2.1 Platform Darwin Hafezs-MacBook-Pro.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000 arm64 Subsystem assert What st...

X Description: Version v25.2.1 Platform Darwin Hafezs-MacBook-Pro.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000 arm64 Subsystem assert What st...

Opengraph URL: https://github.com/nodejs/node/issues/61346

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug] assert.strictEqual OOM on objects with deeply shared references","articleBody":"### Version\n\nv25.2.1\n\n### Platform\n\n```text\nDarwin Hafezs-MacBook-Pro.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000 arm64\n```\n\n### Subsystem\n\nassert\n\n### What steps will reproduce the bug?\n\n```javascript\n// Run with: node --max-old-space-size=512 repro.js\n'use strict';\nconst assert = require('assert');\n\n// Create an object graph where many unique paths converge on shared objects.\n// This delays circular reference detection and creates exponential growth\n// in util.inspect output at high depths.\n\nfunction createBase() {\n  const base = { id: 'base', models: {}, schemas: {}, types: {} };\n  for (let i = 0; i \u003c 5; i++) {\n    base.types[`type_${i}`] = {\n      name: `type_${i}`,\n      base,\n      caster: { base, name: `type_${i}_caster` },\n      options: {\n        base,\n        validators: [\n          { base, name: 'v1' },\n          { base, name: 'v2' },\n          { base, name: 'v3' },\n        ],\n      },\n    };\n  }\n  return base;\n}\n\nfunction createSchema(base, name) {\n  const schema = { name, base, paths: {}, tree: {}, virtuals: {} };\n  for (let i = 0; i \u003c 10; i++) {\n    schema.paths[`field_${i}`] = {\n      path: `field_${i}`,\n      schema,\n      instance: base.types[`type_${i % 5}`],\n      options: {\n        type: base.types[`type_${i % 5}`],\n        validators: [\n          { validator: () =\u003e true, base, schema },\n          { validator: () =\u003e true, base, schema },\n        ],\n      },\n      caster: base.types[`type_${i % 5}`].caster,\n    };\n  }\n  schema.childSchemas = [];\n  for (let i = 0; i \u003c 3; i++) {\n    const child = { name: `${name}_child_${i}`, base, schema, paths: {} };\n    for (let j = 0; j \u003c 5; j++) {\n      child.paths[`child_field_${j}`] = {\n        path: `child_field_${j}`,\n        schema: child,\n        instance: base.types[`type_${j % 5}`],\n        options: { base, schema: child },\n      };\n    }\n    schema.childSchemas.push(child);\n  }\n  return schema;\n}\n\nconst base = createBase();\nconst schema1 = createSchema(base, 'Schema1');\nconst schema2 = createSchema(base, 'Schema2');\n\n// These are different objects, so comparison should fail with AssertionError\nassert.strictEqual(schema1, schema2);\n```\n\n### How often does it reproduce? Is there a required condition?\n\n100% reproducible. The condition is having objects with many unique paths that converge on shared objects (common in ORMs like Mongoose where schemas reference a shared \"base\" object).\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`assert.strictEqual` should throw an `AssertionError` with a diff showing the objects are not reference-equal. The error message can be truncated if very large, but the process should not crash.\n\n### What do you see instead?\n\nThe process crashes with OOM:\n```\nFATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory\n```\n\nThe OOM happens because `util.inspect` expands each unique path through the object graph separately. For objects where many paths converge on shared objects (common in ORMs), the number of unique paths grows exponentially. With `depth: 1000`, the expansion runs long enough to produce 100+ MB strings before hitting circular reference markers.\n\n### Additional information\n\nThis was discovered while working with Mongoose documents. The issue is in `lib/internal/assert/assertion_error.js` where `inspectValue()` has no output size limit.\n\n**Potential fixes:**\n\n1. **Truncate inspect output** (e.g., at 2MB) before passing to the diff algorithm\n2. **Skip diff entirely for huge objects** - just show \"Objects are not equal (output too large to diff)\"\n3. **Smarter truncation** - find where objects differ first, truncate around that area. However, this is complex to implement and the performance impact is probably negative compared to current solution: for objects with exponential paths, even traversing them to find differences could be expensive, and the subtree around the difference may still contain references to shared objects that cause the same explosion.\n\n**Trade-off with truncation:**\n\nIf both objects produce very large inspect output and happen to match exactly in the first 2MB but differ later, the diff would appear identical even though the assertion failed. However:\n- The alternative is an OOM crash, which is worse\n- The assertion result is still correct (`===` failed)\n- A truncation marker (`... [truncated]`) indicates output was cut off\n- Users can examine `error.actual` and `error.expected` programmatically for further investigation\n\nI'm happy to submit a PR with a fix.","author":{"url":"https://github.com/AbdelrahmanHafez","@type":"Person","name":"AbdelrahmanHafez"},"datePublished":"2026-01-11T17:51:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/61346/node/issues/61346"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:853b0652-c33a-57b0-1625-fdc80b9422cd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB128:29A342:281C9A1:34DEEC8:696485C4
html-safe-nonce3758e63fce9ecbd2cc6c1fd4c86ee87ac2a04ae140f80ac56d753ee59890475a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTI4OjI5QTM0MjoyODFDOUExOjM0REVFQzg6Njk2NDg1QzQiLCJ2aXNpdG9yX2lkIjoiNjEyNjc5NzAxMDE1Nzk5NTQ2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac86283c72babc65f6d41fad0edd8f84e9c7ab2a4cda7bdb49d4020a0e2eadfb7f
hovercard-subject-tagissue:3801712581
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/61346/issue_layout
twitter:imagehttps://opengraph.githubassets.com/dc84bef7a9fc5d1aac48b1b1ff3397fe6a602a1f2743db37b3ad0ee7a60eef6d/nodejs/node/issues/61346
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/dc84bef7a9fc5d1aac48b1b1ff3397fe6a602a1f2743db37b3ad0ee7a60eef6d/nodejs/node/issues/61346
og:image:altVersion v25.2.1 Platform Darwin Hafezs-MacBook-Pro.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000 arm64 Subsystem assert What st...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameAbdelrahmanHafez
hostnamegithub.com
expected-hostnamegithub.com
Nonebaa7d9900fdf7b27d604f36887af878d569cfbdcf97126832a5f4f0caf0c6ba5
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release842eff1d11f899d02b6b3b98fa3ea4860e64b34e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/issues/61346#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F61346
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F61346
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/61346
Reloadhttps://github.com/nodejs/node/issues/61346
Reloadhttps://github.com/nodejs/node/issues/61346
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/issues/61346
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 34.3k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 115k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.7k https://github.com/nodejs/node/issues
Pull requests 688 https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects 3 https://github.com/nodejs/node/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/nodejs/node/security
Please reload this pagehttps://github.com/nodejs/node/issues/61346
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/61346
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/61346
#61347https://github.com/nodejs/node/pull/61347
[Bug] assert.strictEqual OOM on objects with deeply shared referenceshttps://github.com/nodejs/node/issues/61346#top
#61347https://github.com/nodejs/node/pull/61347
https://github.com/AbdelrahmanHafez
https://github.com/AbdelrahmanHafez
AbdelrahmanHafezhttps://github.com/AbdelrahmanHafez
on Jan 11, 2026https://github.com/nodejs/node/issues/61346#issue-3801712581
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.