edge-runtime icon indicating copy to clipboard operation
edge-runtime copied to clipboard

`new Object().constructor === Object` returns `false`

Open fabian-hiller opened this issue 1 year ago • 3 comments

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

fabian-hiller avatar May 27 '24 22:05 fabian-hiller

Just ran into this too. Easier reproduction:

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

flostellbrink avatar Jun 12 '24 22:06 flostellbrink

I think this is the root cause of this issue https://github.com/flightcontrolhq/superjson/issues/302, would appreciate an answer from the maintainers :)

aldebout avatar Oct 17 '24 10:10 aldebout

+1

zachweinberg avatar Nov 27 '24 16:11 zachweinberg