0

如果我打电话req.file('files')而不打电话updload(例如因为我抛出验证错误)应用程序崩溃。

const files = req.file('files')
if (!files || files.length === 0) {
  throw "MISSING_ARGUMENTS"; // intentally fails here
}
file.upload() // not reaching here

错误 :

events.js:173
      throw er; // Unhandled 'error' event
      ^

Error: EMAXBUFFER: An Upstream (`NOOP_files`) timed out before it was plugged into a receiver. It was still unused after waiting 4500ms. You can configure this timeout by changing the `maxTimeToBuffer` option.
    at Timeout.<anonymous> (../node_modules/sails/node_modules/skipper/standalone/Upstream/Upstream.js:86:15)
    at listOnTimeout (timers.js:327:15)
    at processTimers (timers.js:271:5)
Emitted 'error' event at:
    at Upstream.fatalIncomingError (../node_modules/sails/node_modules/skipper/standalone/Upstream/prototype.fatalIncomingError.js:95:8)
    at Timeout.<anonymous> (../node_modules/sails/node_modules/skipper/standalone/Upstream/Upstream.js:93:12)
    at listOnTimeout (timers.js:327:15)
    at processTimers (timers.js:271:5)
Waiting for the debugger to disconnect...
Error: EMAXBUFFER: An Upstream (`NOOP_files`) timed out before it was plugged into a receiver. It was still unused after waiting 4500ms. You can configure this timeout by changing the `maxTimeToBuffer` option.
    at Timeout.<anonymous> (../node_modules/sails/node_modules/skipper/standalone/Upstream/Upstream.js:86:15)
    at listOnTimeout (timers.js:327:15)
    at processTimers (timers.js:271:5)
Emitted 'error' event at:
    at Upstream.fatalIncomingError (../node_modules/sails/node_modules/skipper/standalone/Upstream/prototype.fatalIncomingError.js:95:8)
    at Timeout.<anonymous> (../node_modules/sails/node_modules/skipper/standalone/Upstream/Upstream.js:93:12)
    at listOnTimeout (timers.js:327:15)
    at processTimers (timers.js:271:5)

4

1 回答 1

0

我也面临同样的问题,在我的情况下,我检查了allParams()这将防止应用程序崩溃。

const fileDetials = !('image' in req.allParams()) ? req.file('fieldName') : '';
于 2020-09-30T09:02:33.070 回答