New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Runner VM Bug] behavior of {}.constructor === Object
does not match node behavior
#141
Comments
Object
constructor{}.constructor === Object
does not match node behavior
Hey! 👋 Quite a few other people have faced this issue:
As explained here #109 (comment), this behaviour was originally added to make Rust development easier. However, I'm beginning to think making this the default was a bad idea... 😅 While we can still making breaking changes before the full v2 release, I'll probably switch this over to requiring something like a |
This was initially added to make it easier to run Rust workers in Miniflare, as `wasm-bindgen` frequently generates this code. However, the implementation caused `Object` prototype/constructor checks to fail in JavaScript. The previous behaviour can be restored with the `--proxy-primitive`/`miniflare.proxy_primitive_instanceof`/ `proxyPrimitiveInstanceOf` CLI/`wrangler.toml`/API option. Closes #109 Closes #137 Closes #141 Closes cloudflare/workers-sdk#91
Hey! 👋 Miniflare |
This was initially added to make it easier to run Rust workers in Miniflare, as `wasm-bindgen` frequently generates this code. However, the implementation caused `Object` prototype/constructor checks to fail in JavaScript. The previous behaviour can be restored with the `--proxy-primitive`/`miniflare.proxy_primitive_instanceof`/ `proxyPrimitiveInstanceOf` CLI/`wrangler.toml`/API option. Closes #109 Closes #137 Closes #141 Closes cloudflare/workers-sdk#91
Minimal Repro
Miniflare's current, incorrect output
Ideal, expected output
Rationale for fixing bug
I came across this bug while attempting to use the React Material UI library,
@mui/material
. After copying their code and debugging cryptic errors, it led me to this crucial difference between a typical node environment and miniflare that prevented the code from running correctly.This specific behavior is used in
deepmerge
of Material UI, which is use to merge default theme values together. Specifially, this check can be found here: https://github.com/mui-org/material-ui/blob/a9903917f919092f80d84075f39fb51d51f241f2/packages/mui-utils/src/deepmerge.ts#L1-L3. The bug from a user standpoint (when using Material UI) looks as such:Software versions
The text was updated successfully, but these errors were encountered: