Skip to content

Tell why uv_fs_open() failed - #104

Open
danog wants to merge 1 commit into
amphp:4.xfrom
danog:fix-uv-open-errors-4.x
Open

danog wants to merge 1 commit into
amphp:4.xfrom
danog:fix-uv-open-errors-4.x

Conversation

@danog

@danog danog commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

756b1cb ("Fix uv_fs_open return value handling") maps the error code that ext-uv 0.3 passes to the uv_fs_open() callback to null, so that read() and write() throw FilesystemException instead of a TypeError. But the message loses the error: "Failed opening write file handle" whether the disk is full, the directory is missing or permission is denied.

doFsOpen() now throws itself, with the path and libuv's error (uv_strerror()): Failed opening file handle to /nonexistent-dir/x: no such file or directory. That also removes the two duplicated checks in the callers.

Tests

  • Two new tests in FilesystemDriverTest cover every driver: a failed read or write throws FilesystemException. They guard against the regression that 756b1cb fixed; before it, ext-uv 0.3 gave a TypeError.
  • The rest of the suite has the same results with and without this change. On ext-uv 0.3, ParallelFileTest::testSimultaneousLock / testTryLockLoop and UvFileTest::testClose / testWriteAfterClose fail on 4.x either way.
  • psalm reports no errors.

The 3.x backport of 756b1cb, with this change, is #103.

https://claude.ai/code/session_0185K6MyhFXHvLLtf79c6Xif

756b1cb turned the error code that ext-uv 0.3 passes to the uv_fs_open()
callback into null, so that read() and write() throw FilesystemException
instead of passing it on as a file handle (a TypeError), but without
the error: "Failed opening write file handle" on a full disk, a missing
directory or a permission error alike. doFsOpen() now throws itself,
with the path and the error of libuv (uv_strerror()), and tests check
that a failed read or write throws FilesystemException with every
driver.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant