Can't return fail status inside server endpoint Nuxt 3

Viewed 46

I want to return status 500 or 204 depending if something fails. However if I do following inside endpoint:

export default async (req, res) => {

 res.statusCode = 204;
 res.end();

}

I get following error in Nuxt 3 backend console:

ERROR [proxy] write EPIPE
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16)

Any idea why this is happening?

https://codesandbox.io/live/191a44154e4?file=/server/api/test.ts In here it seems to work just fine.

I'm using Node v14.17.6 on MacOS Anyone is able to replicate this error? It does seem to be related to my local env.

Edit 1:

Looks like status is actually being returned, as intended, it's just that error is still there. Doesn't seem to effect the rest of the app.

Tested with different node versions v16 and v17, error still there.

Edit 2:

Issue mysteriously disappeared.

0 Answers
Related