(reason)
| 2293 | } |
| 2294 | |
| 2295 | function fail(reason) { |
| 2296 | if (closed || errored) return; |
| 2297 | errored = true; |
| 2298 | error = reason ?? new ERR_INVALID_STATE('Failed'); |
| 2299 | // `writer.fail()` is always an error path, so the wire code on |
| 2300 | // RESET_STREAM must never be `0n` (which means "no error" in |
| 2301 | // most application protocols). Resolve the code in priority |
| 2302 | // order: |
| 2303 | // 1. If `reason` is a `QuicError`, use its explicit |
| 2304 | // `errorCode`. |
| 2305 | // 2. Otherwise fall back to the negotiated application's |
| 2306 | // "internal error" code, surfaced via |
| 2307 | // `QuicSessionState.internalErrorCode`. For HTTP/3 this is |
| 2308 | // `H3_INTERNAL_ERROR` (0x102); for raw QUIC applications |
| 2309 | // it falls back to the QUIC transport-layer |
| 2310 | // `INTERNAL_ERROR` (0x1). |
| 2311 | const code = QuicError.isQuicError(error) ? |
| 2312 | error.errorCode : |
| 2313 | getQuicSessionState(stream.#inner.session).internalErrorCode; |
| 2314 | handle.resetStream(code); |
| 2315 | if (drainWakeup != null) { |
| 2316 | drainWakeup.reject(error); |
| 2317 | drainWakeup = null; |
| 2318 | } |
| 2319 | } |
| 2320 | |
| 2321 | const writer = { |
| 2322 | __proto__: null, |
no test coverage detected