However, upon receiving more than one such field, e.g. fruits[]=apple and fruits[]=banana, the whole Node process crashes with this stack trace:
RangeError: Maximum call stack size exceeded
at Function.keys (<anonymous>)
at reconcile ([redacted]/node_modules/async-busboy/index.js:193:22)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
at reconcile ([redacted]/node_modules/async-busboy/index.js:202:12)
There are 2 problems here. I propose the following solutions:
There should be no process crash, in any circumstances. Upon any error, even internal, the exception should be thrown. It seams that the underlying busboy module poorly handles errors inside registered event handlers.
Suggested solution: wrap any internal field and file processing function with a try..catch, which would reject the main promise.
This use case is very common and should be handled properly. And making your own parser can be difficult and sometimes even unsafe.
I think, in general, TJ’s qs module could (and maybe even should) be used here for robust field parsing and aggregating. Off the top of my head:
A common use case is to use array fields with no specified indexes, e.g.:
However, upon receiving more than one such field, e.g.
fruits[]=apple
andfruits[]=banana
, the whole Node process crashes with this stack trace:There are 2 problems here. I propose the following solutions:
busboy
module poorly handles errors inside registered event handlers. Suggested solution: wrap any internal field and file processing function with a try..catch, which would reject the main promise.qs
module could (and maybe even should) be used here for robust field parsing and aggregating. Off the top of my head: