Closed tomaratyn closed 4 months ago
The absence of this property caused Node's OutgoingMessage.prototype.setHeader function to fail as it checks for null but not for falsey or undefined.
When setHeader fails with unenv then nuxt can have problems properly rendering error pages for API routes/middleware.
The current re-implementation of ServerResponse is missing the property kOutHeaders. The absence of this property means that it's undefined but Node tests using === null to check if the value needs to be initialized (see https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L709).
ServerResponse
kOutHeaders
undefined
=== null
Due to this when a Nuxt server route has an error it can fail to render since Nuxt will use Nitro's localFetch which in turn uses unenv's createFetch which in turn uses unenv's ServerResponse.
localFetch
createFetch
Actually that property can't be a string, it has to be a Symbol that is not exported by Node. This approach won't work.
The absence of this property caused Node's OutgoingMessage.prototype.setHeader function to fail as it checks for null but not for falsey or undefined.
When setHeader fails with unenv then nuxt can have problems properly rendering error pages for API routes/middleware.
๐ Linked issue
โ Type of change
๐ Description
The current re-implementation of
ServerResponse
is missing the propertykOutHeaders
. The absence of this property means that it'sundefined
but Node tests using=== null
to check if the value needs to be initialized (see https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L709).Due to this when a Nuxt server route has an error it can fail to render since Nuxt will use Nitro's
localFetch
which in turn uses unenv'screateFetch
which in turn uses unenv'sServerResponse
.๐ Checklist