Double Response (ERR_HTTP_HEADERS_SENT) in addProjectToCollection controller
メンテナーはふだん 3 日以内に返信
@dpoppe7 がすでに取り組んでいます。
2026年3月10日 から。
評価
この issue はまだ評価されていません。
説明
p5.js version
1.11.11
What is your operating system?
Mac OS
Web browser and version
Safari 17.6
Actual Behavior
The addProjectToCollection controller (found in server/controllers/collection.controller.js) contains a logic flaw in its Promise handling that leads to a server crash (ERR_HTTP_HEADERS_SENT).
When a validation error occurs (e.g. a collection or a project is not found), the updateCollection function correctly sends a failure response to the client. However, it then returns null to the next block in the Promise chain rather than "short-circuiting" the execution.
addProjectToCollection.js :
First response sent to client here.
Returning 'null' doesn't stop the Promise chain. It passes 'null' to the next .then() block.
function updateCollection([collection, project]) {
if (collection == null) {
sendFailure(404, 'Collection not found');
return null;
}
Then, even if updateCollection returned null, .then(populateReferences) runs.
Second response occurs when .then(sendSuccess), attempts to send 200OK and crash.
return Promise.all([collectionPromise, projectPromise])
.then(updateCollection)
.then(populateReferences)
.then(sendSuccess)
.catch(sendFailure);
Error in Terminal:
node:_http_outgoing:655
throw new ERR_HTTP_HEADERS_SENT('set');
^
Error: Cannot set headers after they are sent to the client
Expected Behavior
When a resource (Collection or Project) is not found, the server should respond with a 404 Not Found and terminate the request lifecycle immediately.
The Promise chain should be short-circuited so that subsequent .then() blocks (like populateReferences and sendSuccess) are never executed after a failure response has been sent. The Node process should remain operational, and no ERR_HTTP_HEADERS_SENT error should be triggered.
Steps to reproduce
Steps:
This bug is triggered by a race condition where the Frontend UI becomes "stale" due to actions in another session/tab. For example:
- Ensure user is logged in
- Open the p5.js Web Editor in two separate browser tabs (Tab A and Tab B).
- In Tab A: Open the "Add to Collection" modal for any sketch. The list of existing collections is displayed, if none, create one.
- In Tab B, delete the collection that you intend to add the sketch to.
- Back in Tab, click the button to add the sketch to that (now deleted) collection.
Observed Result: The server identifies the collection is missing, sends a 404, but then fails to stop execution, attempts a second response, and crashes the backend process.
Also happens when: user has a sketch open in Tab A, deletes it in Tab B, and then attempts to add the now deleted sketch from Tab A to a collection.
https://github.com/user-attachments/assets/f27acf43-2d59-4b4c-b5a5-2eb618369755
- 主要言語
- JavaScript
- スター
- 1.7k
- フォーク
- 1.7k
- 平均マージ
- 3日 18時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
processing/p5.js-web-editor のほかの issue
-
`PATCH /editor/project/visibility` returns 200 with `null` and doesn't update when `projectId` is a slug対応中かも @Prbhtsgh が今日担当しました。 オープンAwaiting Maintainer Approval Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
processing/p5.js-web-editor#4348 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
-
Fix: example.js stores defaultHTML function reference instead of calling it, causing examples to display raw JavaScript source in preview対応中かも @syedbarkath980 が 5 日前に担当しました。 オープンAwaiting Maintainer Approval Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
processing/p5.js-web-editor#4344 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
signup form gets stuck when signup request fails due to network error対応中かも @PS01K が 34 日前に担当しました。 オープンAwaiting Maintainer Approval Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
processing/p5.js-web-editor#4285 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
-
saveProject throws an error when a network request fails対応中かも @dyk1454683243-sudo が 6 日前に担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
processing/p5.js-web-editor#4276 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
Awaiting Maintainer Approval Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
processing/p5.js-web-editor#4270 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
processing/p5.js-web-editor の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
`yarn vitest:update` (documented) throws locally; local Cypress scripts target an unserved portオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
rescript-lang/rescript-lang.org#1415 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: agent capture drops long Unicode text as punctuation対応中かも @ktz03 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
volcengine/OpenViking#5801 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Deepak3699/Ai_Mentor#244 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nextcloud/collectives#2843 ·
メンテナーはふだん 1 日以内に返信