-
-
Notifications
You must be signed in to change notification settings - Fork 27
BlockingFile operations after destructor run throw TypeErrors #85
Copy link
Copy link
Open
Description
PHP Fatal error: Uncaught TypeError: fseek(): supplied resource is not a valid stream resource in /.../vendor/amphp/file/src/Driver/BlockingFile.php:184
Stack trace:
#0 /.../vendor/amphp/file/src/Driver/BlockingFile.php(184): fseek(Resource id #383, 0, 0)
#1 ...: Amp\File\Driver\BlockingFile->seek(0)
The cycle collector happened to first destroy the BlockingFile instance, then another class wanting to write to it in its destructor.
The fix would be trivial to just also set the handle to null in __destruct. Having it then emit a normal ClosedException.
I'm wondering though, do we really need an explicit fclose() call in BlockingFile destructor, and can't just have it automatically close whenever PHP frees the underlying resource? So that we can just continue using it...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels