Skip to content

chore: catch and rethrow network errors in web #1065

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

Merged
merged 1 commit into from
Apr 22, 2025
Merged

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Apr 16, 2025

What does this PR do?

Sometimes the fetch request on the web sdk might fail and throw unexpected errors. For eg. a user might get a CORS error but wouldnt be very clear about the message as they just see a TypeError (here the error is explicitly logged, but normally they just see a TypeError: Failed to fetch):

Screenshot 2025-04-16 at 12 40 59 PM

A user might expect the SDK to just throw AppwriteException and hence an error like this might never be caught, leading to bad DX. The PR catches all errors in call fn and rethrows them as AppwriteException.

Test Plan

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

Yes.

@ChiragAgg5k ChiragAgg5k requested a review from loks0n April 16, 2025 07:20
Copy link
Member

@loks0n loks0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When they send an invalid origin, seems to work well.

What about if the CORS is controlled by the browser side

@christyjacob4 christyjacob4 merged commit 346da22 into master Apr 22, 2025
37 checks passed
@christyjacob4 christyjacob4 deleted the pla-2452 branch April 22, 2025 13:19
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.

3 participants