Skip to content

fix: handle network errors in saveProject (#4276) - #4304

Closed
PS01K wants to merge 1 commit into
processing:developfrom
PS01K:fix/save-project-network-error
Closed

fix: handle network errors in saveProject (#4276)#4304
PS01K wants to merge 1 commit into
processing:developfrom
PS01K:fix/save-project-network-error

Conversation

@PS01K

@PS01K PS01K commented Sep 10, 2026

Copy link
Copy Markdown

Issue:

Fixes #4276

When saving a project (PUT /projects/:id for updates or POST /projects for new sketches) fails due to a network error, request timeout, or server disconnection, Axios creates an error object where error.response is undefined.

Previously, both .catch() handlers in saveProject() directly accessed response.status (if (response.status === 403) ...) and response.data (dispatch(projectSaveFail(response.data))). Because response is undefined, this threw an unhandled TypeError: Cannot read properties of undefined (reading 'status'), causing an unhandled promise rejection instead of gracefully executing save failure handling.

Changes:

  • client/modules/IDE/actions/project.js:
    • Guarded response?.status === 403 and response?.status === 409 checks in both update (PUT) and creation (POST) catch blocks using optional chaining.
    • Safely passed response?.data to projectSaveFail(response?.data).
  • client/modules/IDE/actions/project.unit.test.js:
    • Added unit test suite covering saveProject for existing project update and new project creation under network error conditions (error.response undefined), verifying that endSavingProject, toast notification, and projectSaveFail are dispatched without throwing TypeError.
    • Verified 403 and 409 error modal responses continue to work as expected.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • has no typecheck errors (npm run typecheck)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #4276
  • meets the standards outlined in the accessibility guidelines

- Guard against undefined error.response in saveProject catch blocks using optional chaining

- Pass response?.data safely to projectSaveFail

- Add unit tests covering saveProject network errors and HTTP error responses
@welcome

welcome Bot commented Sep 10, 2026

Copy link
Copy Markdown

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already.

@PS01K PS01K closed this Sep 10, 2026
@PS01K
PS01K deleted the fix/save-project-network-error branch September 10, 2026 19:20
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.

saveProject throws an error when a network request fails

1 participant