Skip to content

Object Prototypes Incorrect #91

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

Closed
johnhenry opened this issue Dec 10, 2021 · 1 comment
Closed

Object Prototypes Incorrect #91

johnhenry opened this issue Dec 10, 2021 · 1 comment

Comments

@johnhenry
Copy link

I'm running into an issue where I believe default prototype for objects is incorrect.
That is, Object.getPrototypeOf({}) is not Object.prototype.

Based on the spec, I'm not entirely sure that this should be the case;
but running this code:

Object.getPrototypeOf({}) === Object.prototype;

returns:

  • true in the browser and on cloudflareworkers.com
  • false when running wrangler pages dev
@mrbbot
Copy link
Contributor

mrbbot commented Dec 10, 2021

Hey! 👋 This is an issue with how Miniflare (the local Workers simulator that powers wrangler pages dev) works that we probably can't fix without breaking other things. See cloudflare/miniflare#109 (comment) for an explanation of the problem.

As mentioned there, we could add an option that lets you choose which behaviour you want:

  • proxy: Miniflare's current behaviour, instanceof always succeeds, but prototype checks don't
  • inside: we do nothing, objects created inside the workers context pass instanceof and prototype checks
  • outside: we pass Object in from the parent context, objects created in the workers context fail instanceof and prototype checks, but things created outside pass

mrbbot added a commit to cloudflare/miniflare that referenced this issue Jan 3, 2022
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
mrbbot added a commit to cloudflare/miniflare that referenced this issue Jan 7, 2022
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
petebacondarwin pushed a commit to petebacondarwin/wrangler2 that referenced this issue Dec 17, 2024
* Update tsconfig files

* Renamed worker directories

* Update tsconfig files in playground and ensure all files are being type checked

* Removed type generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants