stream: `pipeTo` with `preventCancel` can hit `ERR_INTERNAL_ASSERTION` if destination errors before deferred write
オープン
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
Version
v24.16.0
Platform
Linux n37-114-192 5.15.120.bsk.3-amd64 #5.15.120.bsk.3 SMP Debian 5.15.120.bsk.3 Fri Dec 8 12:41:09 UTC x86_64 GNU/Linux
Subsystem
stream
What steps will reproduce the bug?
const { ReadableStream, WritableStream } = require("node:stream/web");
let sourceController;
let destController;
const source = new ReadableStream({
start(controller) {
sourceController = controller;
},
});
const dest = new WritableStream({
start(controller) {
destController = controller;
},
write() {},
});
source.pipeTo(dest, { preventCancel: true }).catch((err) => {
console.log("pipeTo rejected:", err.name, err.message);
});
setImmediate(() => {
destController.error(new Error("destination errored"));
sourceController.enqueue("chunk");
});
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
pipeTo() should reject with the destination error, like v24.14.1 does:
pipeTo rejected: Error destination errored
What do you see instead?
node:internal/assert:11
throw new ERR_INTERNAL_ASSERTION(message);
^
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at assert (node:internal/assert:11:11)
at writableStreamDefaultWriterWrite (node:internal/webstreams/writablestream:982:3)
at node:internal/webstreams/readablestream:1677:33
at process.processTicksAndRejections (node:internal/process/task_queues:104:5) {
code: 'ERR_INTERNAL_ASSERTION'
}
Node.js v24.16.0
Additional information
The error starts to occur in v24.15.0. This lines up strongly with https://github.com/nodejs/node/pull/61800.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された再現を v24.16.0 で実行し、v24.14.1 と比較します。node:internal/webstreams/writablestream の982行目と node:internal/webstreams/readablestream の1677行目を調査し、その後 PR #61800 を確認します。preventCancel が ERR_INTERNAL_ASSERTION ではなく宛先のエラーで reject されることを回帰テストで確認できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, node.js
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 52/100