我正在使用多方。它工作正常,但突然间它出错了。
错误
err: { Error: stream ended unexpectedly
at Form.<anonymous> (/user_code/node_modules/multiparty/index.js:754:24)
at emitNone (events.js:91:20)
at Form.emit (events.js:185:7)
at finishMaybe (_stream_writable.js:514:14)
at endWritable (_stream_writable.js:524:3)
at Form.Writable.end (_stream_writable.js:489:5)
at onend (_stream_readable.js:511:10)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9) status: 400, statusCode: 400 }
代码
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
var multiparty = require('multiparty');
var http = require('http');
var util = require('util');
exports.helloWorld = functions.https.onRequest((request, response) => {
var body = "";
var POST = {};
var form = new multiparty.Form();
form.on('error', function(err) {
console.log('Error parsing form: ' + err.stack);
});
form.parse(request, function(err, fields, files) {
response.status(500).send({
message: err
});
})
});
});
答案 0 :(得分:3)
&#34;流意外结束&#34; 错误意味着在收到完整的多部分表单之前底层TCP套接字已关闭。
正如您所说,这是以前工作的,您应该检查您正在向哪些服务器发出请求的服务器,这些错误可能会提前关闭响应。一个常见原因是响应数据的大小大于服务器或请求/响应头所接受的大小。