Conversation
ronag
left a comment
There was a problem hiding this comment.
I meant on fs write stream. Also probably doc deprecate.
|
You meant:
instead? |
|
Why (doc or runtime) deprecate |
|
I don't get it either. A comment in the linked issue says this:
If the suggestion is to let the GC drive closing files, then that's a bad suggestion for what I hope are obvious reasons. |
Why do we need to have three APIs to close a file stream
Absolutely not. The idea from the linked issue is to enable a case where a user wants to open a steam for a FileHandle and keep the file open when the stream is closed (by explicitly opting into it!). |
benjamingr
left a comment
There was a problem hiding this comment.
This PR should just be a doc-deprecation of https://nodejs.org/api/fs.html#writestreamclosecallback ?
|
Why only doc deprecate instead of moving node itself out of using it? |
|
Throwing will cause unwarranted breakage in the ecosystem. |
|
I did not mean to throw an error, I think that if deprecating an api we should move away from it as well |
when the user pass In other words, should the following test pass? it('should keep file handle open after stream closed when autoClose: false', async () => {
const filePathForHandle = path.resolve(tmpDir, 'tmp-write.txt');
const stream0Text = 'Hello world from stream0';
const destFile = await open(filePathForHandle, 'w');
await destFile.truncate(stream0Text.length + 20);
const stream0 = destFile.createWriteStream({ start: 0, autoClose: false });
await pipeline(stream0Text, stream0);
stream0.destroy(new Error('destroyed'));
assert.notEqual(destFile.fd, -1);
await destFile.close()
}); |
That's entirely unrelated to this PR and s just context around the linked issue |
|
What do you think of the PR so far? Is it in the right direction? |
|
I don't see an actual docs deprecation fo file handle |
mcollina
left a comment
There was a problem hiding this comment.
I think the title of this should be updated, as we are deprecating only close() for file streams, not file handles.
ronag
left a comment
There was a problem hiding this comment.
The unref isn't right. Will leave a more constructive comment next week.
|
|
||
| // Greater than 2 as when file handle is being created the refs is 1 | ||
| // and when the stream is using that file handle the refs is 2 | ||
| if (stream[kHandle]?.[kRefs] > 2) { |
Created after @ronag comment:
#49241 (comment)
same suggestion from @mcollina to remove the
.close