Skip to content

fix(fs-node): close the original descriptor after stream release - #1286

Open
xianjianlf2 wants to merge 1 commit into
streamich:masterfrom
xianjianlf2:fix/filehandle-deferred-close
Open

fix(fs-node): close the original descriptor after stream release#1286
xianjianlf2 wants to merge 1 commit into
streamich:masterfrom
xianjianlf2:fix/filehandle-deferred-close

Conversation

@xianjianlf2

Copy link
Copy Markdown
Contributor

When FileHandle.close() waits for an active Web Stream reference, cancelling that stream runs unref(). The method sets fd = -1 before passing the descriptor to fs.close(), so the pending close rejects with EBADF and the original descriptor remains open. Capture the original descriptor before marking the handle closed, as the immediate close path already does.

Regression tests cover cancellation both before and after a stream read, shared concurrent close calls, and an assertion that the original descriptor is actually closed. Both new cases fail with EBADF before the fix.

Validation: full yarn test, workspace typechecks, and repository Prettier check passed.

AI-assisted implementation and validation.

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

Successfully merging this pull request may close these issues.

1 participant