Skip to content
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

file模式下文件上传问题 #4808

Open
chengfeng12138 opened this issue Nov 20, 2021 · 14 comments
Open

file模式下文件上传问题 #4808

chengfeng12138 opened this issue Nov 20, 2021 · 14 comments

Comments

@chengfeng12138
Copy link

问题:
在 file 模式下,前台通过form表单进行文件上传,同时携带了一些参数(包括图片的base64数据),浏览器控制台的请求一直处于待处理状态,egg服务没有任何的报错日志打印出来, 也没有进入到路由对应的controller方法里,相当于无响应状态。

测试过程:
经测试,当上传的图片大于100KB时就会出现该问题;同时如果删除前台请求参数中的base64信息,请求恢复正常。也已经在配置文件中加入了bodyParser、multipart、multipartParseOptions等配置还是无法解决问题。(猜想是不是缺少了什么配置)

求大佬指教是出了什么问题, 为啥错误日志都没有呢。

image

前台测试页面地址:
https://github.com/chengfeng12138/project1/blob/main/testFile.html

egg配置信息:
const config = exports = { cluster: { listen: { port: 3000, hostname: '127.0.0.1' } }, security: { csrf: false }, bodyParser: { jsonLimit: '100mb', formLimit: '100mb' }, multipart: { mode: 'file', fieldNameSize: 1000, fieldSize: 1024000000000000000, fields: 100000, fileSize: 104857600000000000, files: 1000000, }, multipartParseOptions: { limits: { fieldNameSize: 10000000, fieldSize: 1024000000000000, fields: 1000000, fileSize: 104857600000000000, files: 10000 } } };

@chengfeng12138
Copy link
Author

通过debug断点,确认请求到了egg服务。

@egg-bot
Copy link

egg-bot commented Nov 21, 2021

Hello @chengfeng12138. Please provide a reproducible example following the instruction.

Issues labeled by Need Reproduce will be closed if no activities in 7 days.


@chengfeng12138,请根据这个说明提供最小可复现代码。

如果在 7 天内没有进展会被自动关闭。

@atian25
Copy link
Member

atian25 commented Nov 21, 2021

如上,提供下最小可复现仓库我们看看

@hyj1991
Copy link
Member

hyj1991 commented Nov 22, 2021

切换下 node 版本到 v12.x 再试试看,不行的话按天猪说的把你对应的问题 egg 服务端部分也传上来才好分析下原因

@chengfeng12138
Copy link
Author

切换下 node 版本到 v12.x 再试试看,不行的话按天猪说的把你对应的问题 egg 服务端部分也传上来才好分析下原因

Switch node version to V12. X try again, if not, according to the pig said you corresponding problem, the service part of the egg server to analyze the reason

辛苦大佬看下!

egg服务端代码代码地址:
https://github.com/chengfeng12138/project1/tree/main/eggServer

前台测试页面地址:
https://github.com/chengfeng12138/project1/blob/main/testFile.html

@chengfeng12138
Copy link
Author

如上,提供下最小可复现仓库我们看看

As above, provide a minimum reproducible warehouse for us to look at

egg服务端代码地址如下:
https://github.com/chengfeng12138/project1/tree/main/eggServer

@hyj1991
Copy link
Member

hyj1991 commented Nov 26, 2021

你好,我在 Node-v16.x 下测试了没有问题,如果需要对文件限制的话,参考文档给 multipart 的配置项增加一个 fileExtensions 配置,比如 fileExtensions: ['.txt'] 那么只能上传后缀为 txt 的文件。

@hyj1991
Copy link
Member

hyj1991 commented Nov 26, 2021

image

@chengfeng12138
Copy link
Author

你好,我在 Node-v16.x 下测试了没有问题,如果需要对文件限制的话,参考文档给 multipart 的配置项增加一个 fileExtensions 配置,比如 fileExtensions: ['.txt'] 那么只能上传后缀为 txt 的文件。

您好, 我这边测试是上传超过100Kb的图片文件才有问题, 麻烦再帮忙看下呢

@shuidian
Copy link

切换下 node 版本到 v12.x 再试试看,不行的话按天猪说的把你对应的问题 egg 服务端部分也传上来才好分析下原因

这里有什么说道吗?我这边也遇到类似问题,就是node12版本下,文件上传ok的,但是到14以上,就会出现跟题主一样的现象,任何日志都没有,然后请求一直卡在Initial connection阶段,最终超时。

@shuidian
Copy link

切换下 node 版本到 v12.x 再试试看,不行的话按天猪说的把你对应的问题 egg 服务端部分也传上来才好分析下原因

这里有什么说道吗?我这边也遇到类似问题,就是node12版本下,文件上传ok的,但是到14以上,就会出现跟题主一样的现象,任何日志都没有,然后请求一直卡在Initial connection阶段,最终超时。

@hyj1991

@shuidian
Copy link

shuidian commented Jan 12, 2022

这个问题跟 #4820 应该是同一个原因,是co-busboy里面有问题。但是我测试了一下把co-busboy升级到1.5.0,问题貌似就没有了,好像是co-busboy修复了这个问题?我这边测试在node14和node16上,使用[email protected],文件上传都是ok的。这边建议egg-multipart把co-busboy的依赖版本调整到1.5.0以上应该就ok了。

@yysx
Copy link

yysx commented Apr 15, 2022

我把node从16.x版本降到了12.x解决了这个问题

@FujiBilly
Copy link

@hyj1991 这个issue貌似还没解决?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants