nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.47k stars 280 forks source link

Is HTTP2 push stream actually duplex stream? #4303

Closed vilicvane closed 10 months ago

vilicvane commented 10 months ago

Details

When I try to write to a stream pushed by the server, it throws Error [ERR_STREAM_WRITE_AFTER_END]: write after end. But the type of push stream is duplex.

Node.js version

v20.5.1

Example code

No response

Operating system

Windows

Scope

runtime

Module and version

Not applicable.

vilicvane commented 10 months ago

Okay, so the answer is yes but not really.

A push stream, if I understand it correctly, can be treated as a response to push promise. So, the readable part on the server side ends immediately thus the duplex is only writable. In other words, for the client, the duplex is not writable as the "request" has already finished.