keystonejs / keystone

The most powerful headless CMS for Node.js — built with GraphQL and React
https://keystonejs.com
MIT License
9.01k stars 1.13k forks source link

BadRequestError: Request disconnected during file upload stream parsing. #8242

Open jordie23 opened 1 year ago

jordie23 commented 1 year ago

It's hard to replicate this exactly because it may be a network problem.

We see an uncaught error sometimes when uploading files (specifically using the keystone cloudinary field, however it seems it may be related to keystone core instead). It causes our node process to crash in production as it's uncaught.

BadRequestError: Request disconnected during file upload stream parsing.
at IncomingMessage.<anonymous> (/home/node/app/src/node_modules/graphql-upload/processRequest.js:338:11)
at Object.onceWrapper (events.js:519:28)
at IncomingMessage.emit (events.js:400:28)
at abortIncoming (_http_server.js:570:9)
at socketOnClose (_http_server.js:562:3)
at Socket.emit (events.js:412:35)
at TCP.<anonymous> (net.js:686:12)
Emitted 'error' event on ReadStream instance at:
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
expose: true,
statusCode: 499,
status: 499

From what I can tell this error is being thrown by the graphql-upload library here: https://github.com/jaydenseric/graphql-upload/blob/master/processRequest.mjs#L336-L341 - maybe by simulating that you'll be able to replicate the issue?

It'd be great if this error was caught and handled.

I'd expect an error response to be returned from the graphql upload request in the usual way, without the process exiting. Some sort of retry would be amazing, but I'll take not crashing for now. :)

node version is 14.21.1

@keystone/core is at 4.0.1

mmachatschek commented 1 year ago

this may be related to https://github.com/keystonejs/keystone/issues/7984

@jordie23 ping