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 find().toArray(): an inherited static (MongoDBResponse.make) called through a subclass reads its module-scope bindings wrongly (value is not a function) #11200
mongodb 7.5.0's collection.find({}).toArray() fails with TypeError: value is not a function. This is the next CRUD-fixture blocker after #11187 (find().sort()) and #11157. The failing call is CursorResponse.make(bson). make is a static method inherited from MongoDBResponse, and it uses module-scope bindings. When it is called through the subclass, those bindings read wrong values. The instrumented fixture showed typeof isErrorResponse === "object" when make ran as CursorResponse.make and "function" when it ran as MongoDBResponse.make.
It reproduces on origin/main25ef463 without any package. It also reproduces with PR #11199 (#11187) and PR #11188 applied.
The module-scope bindings that make reads: lib_1, isErr, and Off, which isErr reads.
Remove any one of them and the call succeeds. new Sub(...) called directly works, and so does Base.make. Only the inherited static that is invoked with this = Sub fails.
In mongodb
Fixture: mongodb 7.5.0 + bson 7.3.3, auto-optimize on, perry.compilePackages = mongodb and its deps. connect, deleteMany and insertMany succeed. Then await collection.find({}).toArray() fails, with or without .sort(). The throw originates in Connection.sendWire, at (responseType ?? MongoDBResponse).make(bson) with responseType = CursorResponse. Instrumentation inside MongoDBResponse.make printed:
make this MongoDBResponse ... typeof isErrorResponse = function (insert/delete: fine)
make this CursorResponse ... typeof isErrorResponse = object (find: throws calling it)
Possibly the same family as #10911 (a class's capturing static methods read captures as undefined). Here the captures come back as the wrong values, and only when the static is reached through a subclass.
Activity
fix(runtime): an inherited static reads its DECLARING class evaluatio…