Skip to content

Uncatchable exception from webstream adapter #64120

Description

@basro

Version

v26.3.1

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?

The following code reproduces the bug:

import { connect, createServer } from "net";
import { Duplex } from "stream";

const server = createServer();

server.on("connection", (socket) => {
    socket.end();
});

server.listen(8444, () => {
    console.log("server listening on port 8444");
});

const socket = connect({ host: "localhost", port: 8444 });
const conn = Duplex.toWeb(socket);

const reader = conn.readable.getReader();
const writer = conn.writable.getWriter();

try {
    await reader.read();
    await writer.close();
} catch {}

How often does it reproduce? Is there a required condition?

Happens consistently on Node 26.3.0 and 26.3.1
Doesn't happen on Node 26.2.0

What is the expected behavior? Why is that the expected behavior?

It should not produce an uncatchable exception.

What do you see instead?

Node will exit with the uncaught exception:

node:internal/webstreams/adapters:224
    controller.error(new AbortError());
               ^

TypeError: Cannot read properties of undefined (reading 'error')
    at Socket.<anonymous> (node:internal/webstreams/adapters:224:16)
    at Socket.<anonymous> (node:internal/util:581:20)
    at Socket.onfinish (node:internal/streams/end-of-stream:238:16)
    at Socket.emit (node:events:509:20)
    at finish (node:internal/streams/writable:955:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions