解析回调请求中的多党错误



我正在使用多方。它运行良好,但突然丢了错误。

错误

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
                                                                                    });
                                                          })
                                               });
});

"流意外结束" 错误意味着在收到完整的多部分表单之前关闭了基础TCP插座。

正如您说的那样,您应该检查您要提早关闭响应的任何错误的服务器。一个常见的原因是响应数据的大小比服务器或请求/响应标头大。

相关内容

  • 没有找到相关文章

最新更新