Skip to content
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

new Object().constructor === Object returns false #899

Open
fabian-hiller opened this issue May 27, 2024 · 3 comments · May be fixed by #1047
Open

new Object().constructor === Object returns false #899

fabian-hiller opened this issue May 27, 2024 · 3 comments · May be fixed by #1047

Comments

@fabian-hiller
Copy link

Bug Report

new Object().constructor === Object returns false in Next.js with edge runtime enabled.

A clear and concise description of the behavior.

new Object().constructor === Object should return true.

A clear and concise description of what you expected to happen (or code).

new Object().constructor === Object should return true

Workaround: new Object().constructor === Object.prototype.constructor

With other objects like Date it works: new Date().constructor === Date returns true

Steps to reproduce:

  1. Install Next.js
  2. Add export const runtime='edge' to page.tsx
  3. Add console.log(new Object().constructor === Object) to page.tsx
  4. Run next dev
@flostellbrink
Copy link

Just ran into this too. Easier reproduction:

npx edge-runtime --eval "({}).constructor == Object" -> false
node --eval "console.log(({}).constructor == Object)" -> true

@aldebout
Copy link

I think this is the root cause of this issue flightcontrolhq/superjson#302, would appreciate an answer from the maintainers :)

@zachweinberg
Copy link

+1

Schniz added a commit that referenced this issue Nov 28, 2024
this resolves #899 with a caveat that an object that was created outside
of the VM will obviously won't satisfy this requirement. However, it will
still be `instaceof Object` which is interesting. I am not sure it'll be easy to solve.
@Schniz Schniz linked a pull request Nov 28, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

4 participants