saveProject throws an error when a network request fails

クローズ 初心者向け
#4,276 コメント 3 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

@dyk1454683243-sudo がすでに取り組んでいます。

2026年10月2日 から。

  • #2 @dyk1454683243-sudo による — マージされずにクローズ
  • #4304 @PS01K による — マージされずにクローズ
  • #4311 @dyk1454683243-sudo による — マージ済み

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript
領域
api, frontend

調査の方向性

saveProject() のエントリポイントと、issue に示されている apiClient.put() の catch ハンドラーから始めます。HTTP レスポンスなしでリクエストが失敗するようにして障害を再現し、その後、既存の保存失敗処理が未処理の rejection や二次的な TypeError を発生させずに実行されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Bug
p5.js version

2.3.2

What is your operating system?

Linux

Web browser and version

firefox 153.0.1

Actual Behavior

When saving a project, if the request fails because of a network error, saveProject() throws a TypeError instead of handling the save failure normally.
the error is:
Cannot read properties of undefined (reading 'status')
this happens because the error handler assumes error.response always exists, but for network errors there is no response.

Expected Behavior

A network error while saving should be handled as a normal save failure without throwing another error.
The user should get the usual save failure handling instead of an unhandled/rejected promise.

Steps to reproduce
Steps:
  1. open an existing saved project and make some changes.
  2. disconnect the network or otherwise make the api request fail without returning an http response.
  3. try to save the project.
  4. saveProject() rejects with:

Cannot read properties of undefined (reading 'status')

Snippet:
apiClient
  .put(`/projects/${state.project.id}`, formParams)
  .catch((error) => {
    const { response } = error;

    if (response.status === 403) {
      // ...
    }
  });

for a network error, error.response is undefined, so accessing response.status throws.
a possible fix would be to check whether response exists before accessing response.status, and handle network errors as a normal save failure.

主要言語
JavaScript
スター
1.7k
フォーク
1.7k
平均マージ
6日 22時間
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

processing/p5.js-web-editor のほかの issue

processing/p5.js-web-editor の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。