Repository navigation
Conversation
ext-uv 0.3 passes the (negative) error code to the uv_fs_open() callback on failure instead of false, so the `!$fh` checks of read() and write() let it through, and it reached uv_fs_fstat()/uv_fs_write() as a file handle: a TypeError instead of a FilesystemException (e.g. a write on a full disk: "uv_fs_write(): Argument amphp#2 ($fd) must be of type resource, int given"). doFsOpen() now throws FilesystemException itself, with the error of libuv (uv_strerror()). 4.x fixed the checks in 756b1cb (without the error): backported here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since ext-uv 0.3, the
uv_fs_open()callback gets a negative error code on failure instead offalse. On 3.x, the!$fhchecks ofUvFilesystemDriver::read()andwrite()let that integer through, and it reachesuv_fs_fstat()/uv_fs_write()as a file handle. The result is aTypeErrorinstead of aFilesystemException. Seen in production on a disk out of inodes (-28,ENOSPC):4.x fixed the checks in 756b1cb, which was never backported. This backports it, and has
doFsOpen()throw theFilesystemExceptionitself, with the path and libuv's error (uv_strerror()):Failed opening file handle to /nonexistent-dir/x: no such file or directory.Tests
FilesystemDriverTestcover every driver: reading a missing file, and writing into a missing directory, must throwFilesystemException. With ext-uv 0.3, both fail on 3.x with theTypeErrorand pass with this change.UvFileTest::testCloseandtestWriteAfterClosealready fail on 3.x with ext-uv 0.3 (noClosedExceptionafterclose()); 4.x changed that code with the locking rework, so it's left out here.#104 adds the error reason to 4.x.
https://claude.ai/code/session_0185K6MyhFXHvLLtf79c6Xif