简体   繁体   English

Sails 应用程序在不调用船长上传时崩溃

[英]Sails app crash when not calling skipper upload

If I call req.file('files') and not calling updload (for example because I throw validation error) the app crashes.如果我调用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

error:错误:

 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)

I was also facing the same issue, in my case, I checked with allParams() that will prevent app from crashing.我也面临同样的问题,就我而言,我检查了allParams()这将防止应用程序崩溃。

const fileDetials = !('image' in req.allParams()) ? req.file('fieldName') : '';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM