You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
(async () => {
const file = await open("./text.txt", 'a+')
let count = 0
while(count < 5) {
await makeAppend(file.appendFile.bind(this))
count++
}
await makeAppend(file.appendFile.bind(this))
await file.close()
})();
async function makeAppend(appendFn) {
console.log("here", appendFn) // <--- prints
await appendFn(`hi there`)
console.log("here") <-- doesn't make it here
}
How often does it reproduce? Is there a required condition?
I was able to reproduce on v18.x lts, all the way up to the current release.
What is the expected behavior? Why is that the expected behavior?
I would have expected to be able to pass the function from the fileHandler into another function.
What do you see instead?
here [Function: bound appendFile]
node:internal/assert:14
throw new ERR_INTERNAL_ASSERTION(message);
^
Error [ERR_INTERNAL_ASSERTION]: handle must be an instance of FileHandle
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at assert (node:internal/assert:14:11)
at fsCall (node:internal/fs/promises:431:3)
at Object.appendFile (node:internal/fs/promises:156:12)
at makeAppend (/home/fed/workspace/index.js:17:9)
at /home/fed/workspace/index.js:8:11 {
code: 'ERR_INTERNAL_ASSERTION'
}
Node.js v21.1.0
Additional information
If I run the file without the .bind(this) i get the following
here [Function: appendFile]
node:internal/fs/promises:431
assert(handle[kRefs] !== undefined,
^
TypeError: Cannot read properties of undefined (reading 'Symbol(kRefs)')
at fsCall (node:internal/fs/promises:431:16)
at appendFile (node:internal/fs/promises:156:12)
at makeAppend (/home/fed/workspace/index.js:17:9)
at /home/fed/workspace/index.js:8:11
Node.js v21.1.0
//Prints :
here [Function: bound appendFile]
here
here [Function: bound appendFile]
here
here [Function: bound appendFile]
here
here [Function: bound appendFile]
here
here [Function: bound appendFile]
here
here [Function: bound appendFile]
here
That is fair that is probably the right approach. I originally got the second error first and was playing around with different ways to solve it and got the first error that said to report to node.
Version
v21.1.0
Platform
6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
I was able to reproduce on v18.x lts, all the way up to the current release.
What is the expected behavior? Why is that the expected behavior?
I would have expected to be able to pass the function from the fileHandler into another function.
What do you see instead?
Additional information
If I run the file without the
.bind(this)
i get the followingscript
The text was updated successfully, but these errors were encountered: