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
console.log(ctx) / util.inspect(ctx.res) throws 'Cannot read private member #headersList' on Node (guarded stub headers) #1000
console.log(ctx) in a handler, and util.inspect(ctx.res) or util.inspect(ctx.res.headers), throw on Node:
TypeError: Cannot read private member #headersList from an object whose class did not declare it
It happens in every scope, not only a cached one. On workerd there is no throw, because its Headers has no Node inspect hook.
Cause
The #713 response-header guard shadows the stub response's headers with a Proxy whose target is a fresh, empty new Headers(). Its get trap forwards to the real rawStubHeaders (packages/rangojs-router/src/server/request-context.ts:1199-1211 on bad36a6b). Node's util.inspect unwraps the Proxy and runs undici's Headers inspect hook. That hook reads #headersList from a receiver that is not a real Headers, and throws.
Repro
This mirrors the guard shape without any router code (Node 22.18):
Through the router: in any handler, console.log(ctx) or console.log(ctx.res) on the Node dev server.
Suggested fix
Give the guarded proxy an own [Symbol.for("nodejs.util.inspect.custom")] that inspects rawStubHeaders. Alternatively, have the trap handle that symbol. #976 / #999 takes the same approach for ctx.request. Add a unit test that inspects ctx, ctx.res and ctx.res.headers.
Activity