property

quic.QuicStream.writer

readonly writer: Writer

Returns a Writer object for pushing data to the stream incrementally. The Writer implements the stream/iter Writer interface with the try-sync-fallback-to-async pattern.

Only available when no body source was provided at creation time or via stream.setBody(). Non-writable streams return an already-closed Writer. Throws ERR_INVALID_STATE if the outbound is already configured.

The Writer has the following methods:

  • writeSync(chunk) — Synchronous write. Returns true if accepted, false if flow-controlled. Data is NOT accepted on false.
  • write(chunk[, options]) — Async write with drain wait. options.signal is checked at entry but not observed during the write.
  • writevSync(chunks) — Synchronous vectored write. All-or-nothing.
  • writev(chunks[, options]) — Async vectored write.
  • endSync() — Synchronous close. Returns total bytes or -1.
  • end([options]) — Async close.
  • fail(reason) — Errors the stream (sends RESET_STREAM to peer). When reason is a QuicError, its error.errorCode is used as the wire code on the resulting RESET_STREAM frame; otherwise the wire code falls back to the negotiated application protocol's "internal error" code (H3_INTERNAL_ERROR (0x102) for HTTP/3, or the QUIC transport-layer INTERNAL_ERROR (0x1) for raw QUIC). See stream.destroy() for a full-stream abort that also resets the readable side via STOP_SENDING.
  • desiredSize — Available capacity in bytes, or null if closed/errored.

The bytes from each writeSync() / writevSync() / write() / writev() input chunk are copied into an internal buffer, so the caller's source buffer is unchanged and may be reused or mutated immediately after the call returns. Callers that want to ensure a source buffer cannot be mutated after handing it off can call ArrayBuffer.prototype.transfer() themselves before passing the buffer.