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
bson ObjectId: every generated id is identical (counter stuck at 1, PROCESS_UNIQUE zero) — mongodb insertMany E11000 #11157
With #11146 (#11139) and #11130 applied to origin/main36892b7, the mongodb 7.5.0 fixture now connects. Its first insertMany fails because every new ObjectId() that bson generates in one process is the same value:
Perry (main 36892b7 + #11146 + #11130, perry-dev, Linux x64, auto-optimize on): distinct 1 rand-zero true counter-step 0
What the generated id says
For 6ab44056 0000000000 000001, the timestamp is correct, all 5 PROCESS_UNIQUE bytes are 0, and the counter is 1 on every call.
The relevant bson code is lib/bson.cjs, class ObjectId extends BSONValue, around lines 2607–2710:
static index = 0;
static PROCESS_UNIQUE = null;
static resetState = () => { this.index = Math.floor(Math.random() * 0x1000000); this.PROCESS_UNIQUE = null; };, called from a static { this.resetState(); … } block.
The constructor does const inc = ObjectId.getInc();, where getInc is return (ObjectId.index = (ObjectId.index + 1) % 0x1000000). It then does const pu = (ObjectId.PROCESS_UNIQUE ??= ByteUtils.randomBytes(5)); and packs the result into this.i0..i3.
A counter that stays at 1 means ObjectId.index reads as 0 on every call. So either the static write in getInc does not persist, or the read and the write resolve to different storage. It is not yet known whether the zero PROCESS_UNIQUE comes from the same fault or from crypto.getRandomValues(Buffer) (nodejsSecureRandomBytes).
I wrote a package-free imitation of those statics: static fields, an arrow resetState using this, a static block, getInc, and ??= in a static method, in both .ts and .cts. It gives Node's output on the same build, so the package's surrounding context seems to be needed. It is not minimized yet.
Activity
fix(hir): route a per-evaluation class's own static reads/writes/call…
test(hir): per-evaluation class declaration statics route through the…
changelog: #11188 per-evaluation class declaration statics (#11157)
fix(hir): a per-evaluation class declaration's members see its evalua…
fix(hir): route a per-evaluation class's own static reads/writes/call…
test(hir): per-evaluation class declaration statics route through the…
changelog: #11188 per-evaluation class declaration statics (#11157)