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
Describe the bug
When making post/put/patch requests to endpoints that accept multipart/form-data uploads (e.g., using@fastify/multipart), fastify-racing incorrectly triggers the abort signal for every request after the payload has been parsed.
To Reproduce
Run the following fastify app
// app.jsconstfastify=require('fastify')()fastify.register(require('fastify-racing'))fastify.register(require('@fastify/multipart'))fastify.post('/data',async(request,reply)=>{constsignal=request.race()constparts=request.parts()constpayload={}console.log('Signal before',signal.aborted)// falseforawait(constpartofparts){if(part.file){payload[part.fieldname]=awaitpart.toBuffer()// to consume the stream}}console.log('Signal after',signal.aborted)// trueawaitfetch('https://example.com',{ signal })// as a result, calls like this will always be abortedreturn"Ok"})conststart=async()=>{awaitfastify.listen({port: 3000})console.log('Server running on http://localhost:3000')}start()
Then call the endpoint, e.g. using curl (assumes app.js is in the same directory):
Additional context
It is probably related to fastify/help#866.
The request.raw.closed event is fired as soon as the request payload is consumed, so unfortunately, it is not a reliable way to detect if the request was aborted.
There is probably no easy fix, if there is one at all.
The text was updated successfully, but these errors were encountered:
Yeah, is pretty much what is described in the issue you referenced.
Nevertheless the bug can be somehow addressed; here we need to check wether the connection is dropped at the moment of the request being in flight.
If the close has been emitted, and the request body is completed/consumed; as long as the connection has not been dropped, the signal can not be aborted yet (in the case of H2, as long as the stream stills alive, the signal should not be aborted).
Yeah, exactly. close is only emitted if the connection has been dropped.
There we just need to ensure that the request hasn't been served yet (as it will remain untouched if the connection is a keep alive and no request is coming).
Describe the bug
When making post/put/patch requests to endpoints that accept multipart/form-data uploads (e.g., using@fastify/multipart), fastify-racing incorrectly triggers the abort signal for every request after the payload has been parsed.
To Reproduce
Run the following fastify app
Then call the endpoint, e.g. using curl (assumes
app.js
is in the same directory):results in
Expected behavior
Expect the signal to not be aborted yet.
Desktop (please complete the following information):
Additional context
It is probably related to fastify/help#866.
The
request.raw.closed
event is fired as soon as the request payload is consumed, so unfortunately, it is not a reliable way to detect if the request was aborted.There is probably no easy fix, if there is one at all.
The text was updated successfully, but these errors were encountered: