Skip to content

Reader of ReadStream.toWeb does not return done: true on readStream finish #44866

Open
@acomanescu

Description

@acomanescu

Version

18.9.0

Platform

macOS

Subsystem

No response

What steps will reproduce the bug?

I've tried the .toWeb approach to convert ServerHttp2Stream to a web stream, but it seems that reader.read() never returns done: true on readable stream finish. ReadableState of ServerHttp2Stream says that readable is finished.

import { createSecureServer } from 'node:http2';
import { Duplex } from 'node:stream';

const options = {};
const sever = createSecureServer(options);

server.on('stream', (stream) => {
  const { readable, writable } = Duplex.toWeb(stream);
  
  const reader = readable.getReader();
  
  while (true) {
    const result = await reader.read();
    console.log(result);  // { value: "<data>", done: false }
  }
});

server.listen(3000);

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

No response

What is the expected behavior?

I expect to receive done: true after readable stream finish event.

What do you see instead?

I receive done: false.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions