Closed e3dio closed 1 year ago
I need to test this more I think I did something wrong
Ok I see, issue was from not immediately attaching res.onData() handler in first synchronous route call, this works now:
app.post('/upload', handle(async (res, req) => {
res.body = getBody(res, req).catch(e => ({ error: e }));
await doAsync();
const body = await res.body;
!res.ab && res.cork(() => {
body.error ? res.writeStatus('400').end(body.error) : res.end('done');
});
}));
I knew this was needed but was not paying attention
Testing making Posts to server, randomly half the time the Post body is missing the first chunk of data, onData never gets called with the first chunk. Below example:
getBody
Result:
Body size 256140 != content-length 288890
Looking at console.logs of chunks, it is always missing the first chunk. Issue happens randomly half the time, other times it works
Testing smaller size body that only needs 1 chunk, onData never calls