nodejs / nodejs/node

stream: `pipeTo` with `preventCancel` can hit `ERR_INTERNAL_ASSERTION` if destination errors before deferred write

未关闭
#63,732 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

在 v24.16.0 上运行提供的复现,并与 v24.14.1 进行比较。检查第 982 行的 node:internal/webstreams/writablestream 和第 1677 行的 node:internal/webstreams/readablestream,然后审查 PR #61800;当回归测试确认 preventCancel 因目标错误而被拒绝,而不是因 ERR_INTERNAL_ASSERTION 被拒绝时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。