-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
bugSomething isn't workingSomething isn't workingreproducibleThis issue can be successfully reproducedThis issue can be successfully reproduced
Description
Self-service
- I'd be willing to implement a fix
Describe the bug
The following code works if it is run as node bug.mjs
, but fails if it is run as yarn node bug.mjs
import { open } from 'fs/promises'
const handle = await open('test.txt', 'w')
await handle.truncate(0)
await handle.close()
Here is the output when running with yarn node
:
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number (20)
at new NodeError (node:internal/errors:372:5)
at validateString (node:internal/validators:120:11)
at Object.isAbsolute (node:path:1157:5)
at VirtualFS.mapToBase (/Users/christian/dev/github/yarnpkg/berry/.pnp.cjs:48282:24)
at VirtualFS.truncatePromise (/Users/christian/dev/github/yarnpkg/berry/.pnp.cjs:48182:45)
at PosixFS.truncatePromise (/Users/christian/dev/github/yarnpkg/berry/.pnp.cjs:48182:24)
at URLFS.truncatePromise (/Users/christian/dev/github/yarnpkg/berry/.pnp.cjs:48182:24)
at FileHandle.truncate (/Users/christian/dev/github/yarnpkg/berry/.pnp.cjs:49331:27)
at file:///Users/christian/dev/github/yarnpkg/berry/bug.mjs:3:14 {
code: 'ERR_INVALID_ARG_TYPE'
}
To reproduce
const { open } = require('fs/promises')
await expect(async function () {
const handle = await open('test.txt', 'w')
await handle.truncate(0)
await handle.close()
}()).resolves.toBeUndefined()
Environment
Binaries:
Node: 17.9.0 - /private/var/folders/2n/50s_kk9s64jcd16qkxnf9b_40000gn/T/xfs-107d9a4f/node
Yarn: 4.0.0-rc.2.dev - /private/var/folders/2n/50s_kk9s64jcd16qkxnf9b_40000gn/T/xfs-107d9a4f/yarn
npm: 8.5.5 - /usr/local/bin/npm
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingreproducibleThis issue can be successfully reproducedThis issue can be successfully reproduced