Comments (9)
I've experienced the same or at least a similar bug in my nextjs application. I've already analyzed it a bit, but haven't opened a PR because I haven't been able to extend the test cases for testing my fix, nor have I been able to provide a simple reproduction environment for the bug.
What I've found so far is that the bug was introduced in v6.4.7
and it occurs in the isTypedArray
function.
I did some digging and found out that my build environment overwrites the [Symbol.toStringTag]
of an object that is a module (e.g. Object.defineProperty({ ... }, Symbol.toStringTag, { value: "Module" })
). This breaks the isObject
check and therefore the code calls the isTypedArray
function from cloneDeep
.
A possible fix would be to test if the constructor is defined:
const isTypedArray = (v: AnyVal): boolean => {
+ const ctor = getConstructor(v);
+ const proto = ctor && Object.getPrototypeOf(ctor) as Callback;
- const proto = Object.getPrototypeOf(getConstructor(v)) as Callback;
return proto && proto.name === "TypedArray";
};
But this will only fix the symptom of the error, not the root cause which is in isObject
.
My current workaround was to downgrade to v.6.4.6
from mingo.
I've just tested through all the versions and the latest working one for our case seems to be 5.1.0
from mingo.
Okay, then it might be a different bug in my case
from mingo.
I will mention that we tracked it down to the same function, it is definitely the build environment messing with that module.
from mingo.
Thanks @eonkleynhans for reporting this issue. Doing a quick comparison between versions, the isObject
function hasn't changed since 5.1.0
. The isTypeArray
function is recent addition to support deep cloning typed arrays when present.
There is a guard to ensure null
and undefined
values aren't passed directly to Object.getPrototypeOf
by delegating to internal classes Null
and Undefined
to represent them. This ensures their constructors always exist.
Besides those two, I am unaware of an object in JS that would not have a constructor.
Can you confirm whether the transpiled JS maintains all checks?
from mingo.
It's possible to actively overwrite the prototype or set it to null
. It seems that vite is doing something like that for modules:
I've put the reproduction example from @eonkleynhans, mentioned in the first post, in a repository to make testing easier: https://github.com/maxnowack/mingo-reproduction-390
from mingo.
Refactoring the isObject
method to also work on these types of objects is a bit hard and I wasn't able to figure out a general solution for that.
Spreading the imported [object Module]
into a plain object when calling useOperators
resolves the TypeError
.
I proposed a fix in #391
from mingo.
As I mentioned here, the TypeError
was already fixed by 254afa6
from mingo.
@kofrasa don't forget to publish the changes to npm 🙂
from mingo.
Related Issues (20)
- Add support for $percentile (aggregation) HOT 2
- Add support for $bitAnd (aggregation)
- Add support for $bitNot (aggregation)
- Add support $bitOr (aggregation)
- Add support for $bitXor (aggregation)
- updateObject fails when the $exists operator is used with $pull HOT 2
- $push with updateObject does not create the array if the fields does not exist HOT 1
- $inc with updateObject does not create the field if it doesn't exist HOT 1
- aggregate() $group stage with mongodb object id as group key only creates one single group HOT 1
- aggregate() $project stage modifies original collection when using negative projection on nested field HOT 2
- AWS SSO HOT 2
- query HOT 1
- $project step omits referenced properties when matching property exists in incoming data HOT 3
- Basic query operators not loaded by default for update operation. HOT 4
- 6.4.11 regression: ESM imports no longer work HOT 4
- mingo.io is expired
- Minify compiled output for publishing
- Support value equality check for custom types using toString
- 6.4.14 regression: ESM imports no longer work HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mingo.