Conversation
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
…ng, and Symbol.asyncDispose Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
…B support Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement
Implement comprehensive FileHandle API with EventEmitter, reference counting, and enhanced streaming
Jul 25, 2025
FileHandle API
Contributor
|
🎉 This PR is included in version 4.20.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
This PR implements a comprehensive FileHandle API to align with Node.js behavior and complete the missing functionality outlined in the issue.
Key Changes
EventEmitter Integration
The FileHandle class now properly extends EventEmitter, enabling full event-based functionality:
on(),emit(),removeListener()and all EventEmitter methodsResource Management
Implemented Node.js-style reference counting system:
refs) to prevent premature closureclose()calls are handled gracefully with promise reuseref()andunref()methods for proper resource lifecycle managementModern API Support
FileHandle[Symbol.asyncDispose]: Added async disposal support for ES2023+ patternsFileHandle#getAsyncId(): Added method returning the file descriptor for async resource trackingEnhanced ReadableStream Implementation
Completely rewrote
readableWebStream()with production-ready features:Example Usage
Testing
The FileHandle implementation is now production-ready with full Node.js compatibility, proper resource management, and modern streaming capabilities.
Fixes #1089.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.