Skip to content

Keep FileReader in DONE state after abort#57692

Open
fallintoplace wants to merge 1 commit into
react:mainfrom
fallintoplace:fix-filereader-abort-state
Open

Keep FileReader in DONE state after abort#57692
fallintoplace wants to merge 1 commit into
react:mainfrom
fallintoplace:fix-filereader-abort-state

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary:

Before #57375, reads never entered LOADING, so the active abort path was effectively unreachable. Now that reads use LOADING, that path calls _reset() before and after transitioning to DONE, leaving the reader in EMPTY after abort() returns.

This differs from the File API abort algorithm, which keeps an active reader in DONE. The final reset also overwrites a replacement read started by an abort handler, and that new read clears the shared _aborted flag before the canceled native promise settles.

This change:

  • keeps an aborted active reader in DONE with a null result
  • skips the old loadend if the abort handler starts another read
  • gives each read an ID so a canceled native promise cannot complete over a newer read

Changelog:

[GENERAL] [FIXED] - Keep FileReader in the correct state after aborting a read.

Test Plan:

  • yarn jest packages/react-native/Libraries/Blob/__tests__/FileReader-test.js --runInBand
  • ./node_modules/.bin/prettier --check packages/react-native/Libraries/Blob/FileReader.js packages/react-native/Libraries/Blob/__tests__/FileReader-test.js
  • ./node_modules/.bin/eslint --max-warnings 0 packages/react-native/Libraries/Blob/FileReader.js packages/react-native/Libraries/Blob/__tests__/FileReader-test.js
  • yarn flow-check

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 25, 2026
@fallintoplace
fallintoplace force-pushed the fix-filereader-abort-state branch from beb7b66 to 71067af Compare July 25, 2026 20:26
@fallintoplace fallintoplace changed the title Fix FileReader abort state handling Keep FileReader in DONE state after abort Jul 25, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant