You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fetch: new Response()/new Request() — instanceof always false and .constructor is undefined (no prototype link) #5433
x instanceof Response (and instanceof Request) is always false, and x.constructor is undefined, for the native Fetch handles — even for an object freshly created with new Response(...). Field access (.status, .headers, …) works, but the prototype/constructor link is missing, so any code that discriminates a union with instanceof Response misbehaves.
Environment
perry 0.5.1189, main @ 0cc6ee14c, built from source
new Response() instanceof Response === true and r.constructor === Response (matching Node/Bun/browsers), so instanceof-based discrimination works.
Impact
Very common idiom — e.g. a guard that returns either a value or a Response:
constauth=gate(c);// AuthContext | Responseif(authinstanceofResponse)returnauth;// always false under perryuse(auth.user.id);// falls through, throws on the Response
This is the cause of a class of TypeError: Cannot read properties of undefined we hit across ~25 admin handlers in a Hono app. Workaround is duck-typing ('status' in x / a field-presence type guard). Related to the constructor-binding work in #2608/#2640.
Activity
fix(fetch): register instanceof kind-probe under web-fetch, not http-…