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

Class is missing Function in prototype chain

Open snystedt opened this issue 2 years ago • 1 comments

The following fails in the edge runtime (but not in the node runtime)

class Foo {
    constructor() {
        ...
    }
    ...
}

const cls = Foo;
cls instanceof Function // true in node runtime, false in edge runtime

Encountered when using the Firebase Client SDK while initializing the auth module where it tries to discern if a passed argument is a class or not.

snystedt avatar Aug 14 '22 05:08 snystedt

It seems all prototypes are broken. Just tried this now,

console.log(Object.prototype)

prints [Object: null prototype] {} in Node, while the edge runtime returns just the empty object, {}

snystedt avatar Aug 18 '22 08:08 snystedt

Hello @snystedt, can you add a reproduction of the issue?

It isn't clear it's related to Edge Runtime:

$ edge-runtime
ƒ => class Foo {}
ƒ => const cls = Foo
ƒ => const result = cls instanceof Function
ƒ => console.log(result)
true

is this a thing you are experiencing after deploy a Next.js project or a middleware via Vercel CLI?

Kikobeats avatar Nov 02 '22 12:11 Kikobeats

I close it due to lack of information for now

Kikobeats avatar Nov 08 '22 17:11 Kikobeats