Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tfjs-core] do not hang on invalid browser files #8517

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tharvik
Copy link
Contributor

@tharvik tharvik commented Feb 15, 2025

tf.io.browserFiles doesn't fail when loading invalid files. or rather, it fails, but never rejects the promise, making the IOHandler.load hang forever.

wrapping the JSON.parse call in a try/catch and rejecting accordingly did the trick. and a small test to try it out.

note: FileReader.readAsText() is a callback way to go around reading files. the promise-based Blob.text() would make BrowserFile.load simpler and safer (but felt ouf-of-scope here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant