Fix buildz.ai workspace loading error#14
Draft
vdimarco wants to merge 1 commit into
Draft
Conversation
…cket init on NEXT_PUBLIC_SOCKET_URL to avoid failed WebSocket attempts in prod without socket server
|
Cursor Agent can help with this pull request. Just |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
This PR addresses two issues: a 500 error when loading
/api/workspacesand a WebSocket connection failure onbuildz.ai/workspace.The
/api/workspacesGET endpoint now includes defensive error handling, returning an empty list of workspaces on failure instead of a server error, allowing the page to load gracefully. Additionally, the Socket.IO client will now only attempt to connect in production environments ifNEXT_PUBLIC_SOCKET_URLis explicitly configured. This prevents WebSocket connection errors when a socket server is not intended to be active or is misconfigured.Fixes #(issue)
Type of Change
Testing
The changes were validated locally. The
/api/workspacesendpoint was tested to ensure it returns an empty array on error and the correct data otherwise. The Socket.IO initialization logic was verified to correctly skip connection whenNEXT_PUBLIC_SOCKET_URLis not set in a production environment. Linters and existing tests were run to ensure no regressions.Reviewers should focus on:
apps/sim/app/api/workspaces/route.tsto ensure graceful degradation.apps/sim/contexts/socket-context.tsxto confirm it correctly prevents connections whenNEXT_PUBLIC_SOCKET_URLis absent in production.Checklist
Screenshots/Videos