website icon indicating copy to clipboard operation
website copied to clipboard

[BUG] Add proper error handling for fetch calls in Feedback and NewsletterSubscribe components

Open sarthakNITT opened this issue 1 month ago • 2 comments

Describe the bug.

Both Feedback.tsx and NewsletterSubscribe.tsx use fetch() without a .catch() block or try/catch wrapper. This causes unhandled promise rejections, and any network failure results in the UI not updating properly or potentially crashing.

Expected behavior

Fetch requests should gracefully handle network errors and update the component state accordingly (e.g., show error UI). The app should never crash due to missing error handling.

Screenshots

.

How to Reproduce

  1. Open the page with the Feedback or Newsletter Subscribe form.
  2. Turn off your internet or simulate offline mode.
  3. Submit the form.
  4. Notice nothing happens and no error is shown.

🖥️ Device Information [optional]

  • Operating System (OS):
  • Browser:
  • Browser Version:

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

sarthakNITT avatar Dec 06 '25 09:12 sarthakNITT

Can i work on this ??

Dsp023 avatar Dec 09 '25 16:12 Dsp023

I tested this by disconnecting the network and can confirm the unhandled rejection behavior in both components.

Proposed fix:

Wrap each fetch call in try/catch (or add .catch() blocks)

Add a small error state to surface UI feedback (e.g., “Something went wrong, please try again”)

Ensure forms disable submit while awaiting response

Add a basic test to verify error handling

Preserve existing behavior for successful submissions

If this approach sounds good, I’d be happy to open a PR for it!

Sparshagarwal29 avatar Dec 09 '25 20:12 Sparshagarwal29