Allow proposal submission on simulator server errors - #7
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Code Review
This pull request introduces robust error handling for the simulation service, allowing users to submit proposals even when the simulation service is unavailable. It defines a custom SimulationServiceError class and handles network or server-side errors gracefully in the UI. The review feedback suggests a minor improvement to ensure informative error messages when response.statusText is empty, which is common in HTTP/2 environments.
| ); | ||
| } | ||
|
|
||
| throw new Error(`Simulation request failed: ${response.statusText}`); |
There was a problem hiding this comment.
In HTTP/2 environments, response.statusText is often empty. To ensure the error message is informative when a non-5xx error (such as a 4xx client error) occurs, it is recommended to fall back to response.status if response.statusText is not available.
| throw new Error(`Simulation request failed: ${response.statusText}`); | |
| throw new Error(`Simulation request failed: ${response.statusText || response.status}`); |
There was a problem hiding this comment.
Pull request overview
This PR updates the proposal simulation flow so that simulator network failures and HTTP 5xx responses are treated as “service unavailable”, and proposal submission is allowed in that case (while still blocking on actual simulation failures and non-server request errors).
Changes:
- Add a
SimulationServiceErrortype (and guard) to distinguish service-unavailable failures from other simulation errors. - Update
simulateProposalto throwSimulationServiceErroron fetch/network failures and HTTP 5xx responses. - Update the Create Proposal page to allow submission when the simulation service is unavailable, and surface that state in the UI.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ui/src/pages/CreateProposal.tsx | Tracks “simulation service unavailable” state, adjusts submit gating, and shows user messaging when the simulator is down. |
| ui/src/lib/simulation.ts | Introduces a service-unavailable error type and classifies fetch/5xx failures accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -184,6 +191,7 @@ export function CreateProposal() { | |||
|
|
|||
| setIsSimulating(true); | |||
| setSimulationResult(null); | |||
Summary
Verification
Note: npm run lint still fails on existing unrelated lint errors across the UI.