-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Getting Error while uploading file "Unexpected end of form at Multipart._final" #5135
Comments
@MissNanLan 能否提供一下可复现的代码库,这样可以快速修复。 |
这种是 multipart 上传数据不正确,你的代码应该要做异常捕获处理。 |
同样问题构造一个非法文件上传http请求,就会报 复现方式:构造一个非法的文件上传请求(比如,将http协议中换行符修改下),请求代码如下: var http = require('follow-redirects').http;
var options = {
'method': 'POST',
'hostname': '127.0.0.1',
'port': 7001,
'path': '/test/fileupload'
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
// http协议中换行符是\r\n,为了构造异常场景,可以去掉\r
var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"files\"; filename=\"test.txt\"\r\nContent-Type: \"text/plain\"\r\n\r\n123456789\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
req.write(postData);
req.end(); 尝试以下方法均无法捕获1、主动监听异常: 这种如何处理,才能防止worker重启?@fengmk2 |
@WinfredWang 我明天重现一下 |
复现成功了,我们会尽快修复。 |
will close by cojs/busboy#31 |
@WinfredWang @MissNanLan 重新安装依赖,已经修复。 |
@atian25 stream 超难得一个真实案例。 |
问题描述
解决办法: 只要将req.pipe 换成 bb.end 即可
报错截图:
![image](https://user-images.githubusercontent.com/22790863/215312356-0baf0566-88bb-4ed9-9c32-69b7ba372704.png)
可复现问题的仓库地址(Reproduction Repo)
无
Node 版本号:
v16.14.2
Eggjs 版本号:
3.3.3
相关插件名称与版本号(PlugIn and Name):
egg-multipart@^3.1.0 co-busboy "^2.0.0" busboy "^1.6.0"
操作平台与版本号(Platform and Version):
macOS Monterey 12.3.1
The text was updated successfully, but these errors were encountered: