Skip to content

FileService improvements - #114428

Merged
Benjamin Pasero (bpasero) merged 7 commits into
masterfrom
alex/fs-improvements
Jan 19, 2021
Merged

Benjamin Pasero (bpasero) merged 7 commits into
masterfrom
alex/fs-improvements

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Jan 15, 2021 •

Copy link
Copy Markdown
Member

Fixes #114024

  • Fix case where a file handle could be left opened if cancellation was requested between the file open and the first file read.
  • Wait for the fileStream to close before throwing a FileOperationError.
  • Add test and fix problem where removing a listener during event delivery would cause subsequent listeners to not be invoked.
  • Report any errors that are not listened to in stream to onUnexpectedError.

… requested between the file open and the first file read.
…ery would cause subsequent listeners to not be invoked.

Also report any errors that are not listened to `onUnexpectedError`.
@bpasero

Benjamin Pasero (bpasero) commented Jan 19, 2021 •

Copy link
Copy Markdown
Contributor

Thanks 👏

I pushed some changes on top after a thorough review:

  • extract methods for the slice(0) change when emitting from the stream
  • some clarifying comments and link to the issue this fixes
  • a utility method that encapsulates the fileStreamClosed promise

I went back and forth for the last piece. Having the new observe method imho makes this a bit cleaner because we can a) have a test for it and b) hide away the fact that you need to install a data listener to drain the stream. This is imho something that the file service should not know about.

An alternative solution would have been to really try to add something like a closed property to the stream, similar to what node.js does. On the other hand, my stream implementation does not try to be a clone of the node.js one, rather it tries to provide the absolute minimum to be functional for us by keeping the interface shape as minimal as possible because it should also work with minimal overhead in browsers.

Waiting for tests to pass and then I will merge this 👍

@alexdima

Copy link
Copy Markdown
Member Author

👍 Really nice changes. One nice thing that comes from the observer is that you could now move the declaration of fileStream back into the try block since it is no longer used in the catch block at all.

@bpasero
Benjamin Pasero (bpasero) merged commit b47aa19 into master Jan 19, 2021
@bpasero
Benjamin Pasero (bpasero) deleted the alex/fs-improvements branch January 19, 2021 09:02
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File service: revisit leaking file handles from error cases causing some of our tests to fail

2 participants