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

Multer 2.0 doesn't work with Node.js 16.0 due to semver-major upgrade #995

Closed
pubmikeb opened this issue Apr 3, 2021 · 3 comments
Closed

Comments

@pubmikeb
Copy link

pubmikeb commented Apr 3, 2021

For file uploading to the cloud, I'm using Multer ("multer": "^2.0.0-rc.2"). With Node.js 15.3.0 everything is working great, after upgrading to 16.0.0 (starting end of March 2021) I'm getting the following error:

node:internal/process/promises:245
          triggerUncaughtException(err, true /* fromPromise */);
          ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received null
    at TempWriteStream.WriteStream (node:internal/fs/streams:360:5)
    at new TempWriteStream (C:\Users\User\IdeaProjects\TMS\node_modules\fs-temp\lib\write-stream.js:6:15)
    at Object.createWriteStream (C:\Users\User\IdeaProjects\TMS\node_modules\fs-temp\lib\temp.js:121:10)
    at Busboy.<anonymous> (C:\Users\User\IdeaProjects\TMS\node_modules\multer\lib\read-body.js:70:27)
    at Busboy.emit (node:events:369:20)
    at Busboy.emit (C:\Users\User\IdeaProjects\TMS\node_modules\busboy\lib\main.js:37:33)
    at PartStream.<anonymous> (C:\Users\User\IdeaProjects\TMS\node_modules\busboy\lib\types\multipart.js:214:13)
    at PartStream.emit (node:events:369:20)
    at HeaderParser.<anonymous> (C:\Users\User\IdeaProjects\TMS\node_modules\dicer\lib\Dicer.js:50:16)
    at HeaderParser.emit (node:events:369:20) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Process finished with exit code 1

When I'm rolling back to 15.3.0 no error occurs.
After some investigation, I've found out that the source of the issue is await asyncUpload(req, res);.
The code snippet:

const _upload = multer({
	limits: {
		fileSize: CONFIG_STORAGE.uploader.maxFileSizeInBytes
	}
}).single("file");

const asyncUpload = promisify(_upload);
await asyncUpload(req, res);

At Node.js thread I've got a response that the change nodejs/node#35187 has broken some compatibility and Multer has to be adjusted to be able to work with Node.js 16.0+

@pubmikeb pubmikeb changed the title Node.js 16.0 compatibility issue due to semver-major upgrade Multer 2.0 doesn't work with Node.js 16.0 due to semver-major upgrade Apr 3, 2021
@ExE-Boss
Copy link

ExE-Boss commented Apr 7, 2021

Actually, this bug is in fs‑temp, which passes null as the path parameter: https://github.com/LinusU/fs-temp/blob/c892a4786eb7e6669076649ad9c6e2cb3631a037/lib/write-stream.js#L6

@pubmikeb
Copy link
Author

pubmikeb commented Apr 7, 2021

I've filled an issue LinusU/fs-temp#5 for fs-temp.
Once an update will be released, there is a need to update dependencies by Multer.

@LinusU
Copy link
Member

LinusU commented Aug 6, 2021

This is fixed in fs-temp 2.0.0 and Multer 2.0.0-rc.3 ✅

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

No branches or pull requests

3 participants