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

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received null #38058

Closed
pubmikeb opened this issue Apr 3, 2021 · 5 comments
Labels
fs Issues and PRs related to the fs subsystem / file system.

Comments

@pubmikeb
Copy link

pubmikeb commented Apr 3, 2021

  • Version: v16.0.0-v8-canary202104037284782541
  • Platform: Windows 10 20H1, x64
  • Subsystem: environment

What steps will reproduce the bug?

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

What's for sure, this issue happens on Node.js 16.0.0+ starting end of March, on Feb. nightly builds everything used to be OK.

@Ayase-252
Copy link
Member

Ayase-252 commented Apr 3, 2021

Yes, it is introduced in #35187 as a semver-major change 2 weeks ago, and will arrive at v16 (see change log #37678).

Since it is a semver-major and is expected to break something. IMO, It seems to require some changes in multer to support Node.js v16.

@Ayase-252 Ayase-252 added the fs Issues and PRs related to the fs subsystem / file system. label Apr 3, 2021
@ExE-Boss
Copy link
Contributor

ExE-Boss commented Apr 6, 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

So, do I understand it correctly that it's a Node.js issue and not Multer?

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Apr 7, 2021

It’s a fs‑temp issue, which is a third‑party package that Multer depends on.

@RaisinTen
Copy link
Contributor

Closing as it's not a bug in Node.js. It's a bug in fs-temp and it should be reported here: https://github.com/LinusU/fs-temp/issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests

4 participants