Repository navigation
Stop hiding read failures on web - #2230
Merged
Merged
Conversation
_streamFromWebPath caught every error and ended the stream, so a read that failed halfway through made readAsByteStream() complete normally with a truncated or empty file. fetchBytesFromWebPath also caught every error and returned null, which made readAsBytes() retry through xFile and lose the original error. Both helpers now return null only for paths that are not blob: or data: URLs and let read errors propagate, so readAsBytes() throws and readAsByteStream() emits the error. Fixes #2229
This was referenced Oct 5, 2026
navaronbracke
approved these changes
Oct 5, 2026
…-failures # Conflicts: # packages/file_picker_web/CHANGELOG.md
The fetch helpers only receive the file URI, so they now take a non-nullable path and _isWebPath no longer needs a null check. Invalid data: URLs are handled without a null assertion, and the changelog entry is shortened.
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.
Fixes #2229
Depends on #2228. This branch is stacked on top of it, so please merge #2228 first. The base will then move to
main.Problem
On web, errors while reading a picked file were swallowed:
_streamFromWebPathcaught every error and ended the stream. A read that failed halfway through madereadAsByteStream()complete normally, handing the app a truncated or empty file as if the read had succeeded.fetchBytesFromWebPathcaught every error and returnednull, soreadAsBytes()retried throughxFileand the original error was lost.fetchStreamFromWebPathreturned an empty stream instead ofnullfor paths that are not web URLs, so thexFilefallback was never used for them.Changes
nullonly for paths that are notblob:ordata:URLs, and let read errors propagate.readAsBytes()throws the original error andreadAsByteStream()emits it on the stream, matching the native platforms.blob:anddata:URLs and for reading a revokedblob:URL. Against the previous code the stream error test fails, which confirms it covers the silent failure.file_picker_web4.0.1 changelog. No public signatures change, so it ships as a patch.Testing
flutter test --platform chromepasses infile_picker_web(16 tests) andflutter analyzeis clean.