Skip to content

BUG: Server actions throwing 500 on the FE server#223

Merged
ZainabImadulla merged 5 commits intomainfrom
server-action-query-wrapper
Dec 11, 2025
Merged

BUG: Server actions throwing 500 on the FE server#223
ZainabImadulla merged 5 commits intomainfrom
server-action-query-wrapper

Conversation

@josh-torre
Copy link
Copy Markdown
Contributor

Description

Problem: When the API returns a "bad request"(anything other 200) it is received by the Next.js server actions layer. This layer then throws an error that is caught by the server which always sends a 500 to the client, no matter if the API returned a 404, 400, 300, etc.

Solution: As prescribed by the Next.js docs (here)[https://nextjs.org/docs/app/getting-started/error-handling] we must return any errors as values to the client. This proposed solution wraps any calls to the API and gracefully handles any errors that occur on the server. Instead, any errors that occur are sent to the client to be handled. Any and all errors in the server actions layer that are "expected" should now only be handled by the client.

Changes:

  • Added query wrappers for all tanstack query functions used
  • Gracefully handle all expected errors on the FE server
  • Unwrap and handle errors on the FE

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas

Copy link
Copy Markdown
Contributor

@ZainabImadulla ZainabImadulla left a comment

Choose a reason for hiding this comment

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

he he ha ha

@ZainabImadulla ZainabImadulla merged commit ddf5354 into main Dec 11, 2025
3 checks passed
@ZainabImadulla ZainabImadulla deleted the server-action-query-wrapper branch December 11, 2025 04:28
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.

2 participants