You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mongodb crashes on connect: require('../../../package.json') in client_metadata.js resolves under Node but not Perry — only reproduces inside the real 162-module graph #10758
Compiling mongodb 7.5.0 from real source succeeds (162 modules, 3m12s), but the driver crashes during client.connect() — inside its own handshake code, before any CRUD runs.
A three-levels-up relative require() of a JSON file, resolving to the package's own package.json. It fires while building the wire-protocol handshake metadata, so it is on the connect path and unavoidable — every mongodb user hits it immediately.
Node resolves this fine; Perry does not, in this graph.
What I could not reproduce, which is the interesting part
Two isolation attempts both failed to reproduce:
A synthetic package literally named mongodb with the same three-levels-deep relative-require-of-JSON shape.
A copy of the real 240-line client_metadata.js dropped into that synthetic package.
Both resolved correctly under Perry. The failure only appears inside mongodb's actual 162-module graph. So the shape alone is not sufficient — something about the surrounding graph (module ordering, a cached resolution, the depth or identity of the requiring module) participates.
That is worth stating prominently because it means the obvious fix — "make three-levels-up relative JSON requires work" — may already be true, and the real defect is in how the path is resolved for this module in this graph. Anyone starting from the error text alone will write a test that passes.
Reproduction
mkdir mongo-probe &&cd mongo-probe
npm install mongodb@7.5.0
# package.json: { "perry": { "compilePackages": ["mongodb"] } }# fixture.ts: connect to a local mongod, insert and read one document
perry compile fixture.ts -o fixture && ./fixture
A local mongod is needed; the crash happens at connect(), before any collection work.
Not determined
Whether the resolution failure is about the relative path, the .json extension, the requiring module's own resolved identity, or a cache interaction — only that it needs the real graph to manifest.
Fixed in v0.5.1632 (merge train 252, 841b605c97) by #10874 — fix(compile): resolve JSON requires from ESM module paths. Regression test crates/perry/tests/source_graph_export_regressions/issue_10758.rs.
Train validation: 173 gap fixtures across seven areas with zero regressions, re-run against the current base after v0.5.1631 changed canonical_dir's path resolution. All ratchets, cargo fmt, and cargo check --workspace --all-targets under -D warnings clean.
Activity
proggeramlug commentedon Sep 21, 2026
Fixed in v0.5.1632 (merge train 252,
841b605c97) by #10874 —fix(compile): resolve JSON requires from ESM module paths. Regression testcrates/perry/tests/source_graph_export_regressions/issue_10758.rs.Train validation: 173 gap fixtures across seven areas with zero regressions, re-run against the current base after v0.5.1631 changed
canonical_dir's path resolution. All ratchets,cargo fmt, andcargo check --workspace --all-targetsunder-D warningsclean.fix(module): keep createRequire JSON requires on the runtime loader