{"record":{"id":"8ee707794faff2a7","repo":"dotnet/runtime","slug":"browserhttpwritestream-rejected","errorCode":null,"errorMessage":"BrowserHttpWriteStream.Rejected","messagePattern":"BrowserHttpWriteStream\\.Rejected","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/http.ts","lineNumber":107,"sourceCode":"    } catch (err) {\n        // ignore\n    }\n}\n\nexport function http_wasm_transform_stream_write (controller: HttpController, bufferPtr: VoidPtr, bufferLength: number): ControllablePromise<void> {\n    if (BuildConfiguration === \"Debug\") commonAsserts(controller);\n    mono_assert(bufferLength > 0, \"expected bufferLength > 0\");\n    // the bufferPtr is pinned by the caller\n    const view = new Span(bufferPtr, bufferLength, MemoryViewType.Byte);\n    const copy = view.slice() as Uint8Array;\n    return wrap_as_cancelable_promise(async () => {\n        mono_assert(controller.streamWriter, \"expected streamWriter\");\n        mono_assert(controller.responsePromise, \"expected fetch promise\");\n        try {\n            await controller.streamWriter.ready;\n            await controller.streamWriter.write(copy);\n        } catch (ex) {\n            throw new Error(\"BrowserHttpWriteStream.Rejected\");\n        }\n    });\n}\n\nexport function http_wasm_transform_stream_close (controller: HttpController): ControllablePromise<void> {\n    mono_assert(controller, \"expected controller\");\n    return wrap_as_cancelable_promise(async () => {\n        mono_assert(controller.streamWriter, \"expected streamWriter\");\n        mono_assert(controller.responsePromise, \"expected fetch promise\");\n        try {\n            await controller.streamWriter.ready;\n            await controller.streamWriter.close();\n        } catch (ex) {\n            throw new Error(\"BrowserHttpWriteStream.Rejected\");\n        }\n    });\n}\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/http.ts#L89-L125","documentation":"Thrown by http_wasm_transform_stream_write when awaiting streamWriter.ready or streamWriter.write(copy) rejects. The original rejection is intentionally swallowed and replaced with this opaque message. It signals that a streaming HTTP request body write failed — most commonly because the underlying fetch/stream was aborted or the server rejected/closed the connection.","triggerScenarios":"Produced during a streaming PUT/POST when the WritableStreamDefaultWriter rejects: the request was aborted (http_wasm_abort), the network dropped, the server returned an error and closed the stream, or the browser does not support request streaming and the stream errored.","commonSituations":"See trigger scenarios.","solutions":["Check whether the request was aborted via CancellationToken and treat abort as expected (catch and suppress).","Verify the server accepts streaming request bodies and that the URL/method/headers are correct.","Confirm the browser supports streaming requests (use http_wasm_supports_streaming_request to gate the feature); fall back to a buffered request if not.","Inspect the muted debug log ('http muted: ...') for the underlying cause, since the thrown error is intentionally opaque."],"exampleFix":"// before: write to a stream without handling rejection\n// await http_wasm_transform_stream_write(controller, ptr, len); // throws opaque\n\n// after: treat abort as expected, surface others\ntry {\n  await http_wasm_transform_stream_write(controller, ptr, len);\n} catch (e) {\n  if (!controller.isAborted) throw e; // real failure\n  // else: expected cancellation\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function streamingRequestSupported(): boolean {\n  return typeof Request !== 'undefined' && 'body' in Request.prototype && typeof ReadableStream === 'function';\n}","tryCatchPattern":"try {\n  await controller.responsePromise; // or the streaming write API\n} catch (e) {\n  if (controller.isAborted) return; // expected\n  throw e;\n}","preventionTips":["Gate streaming requests on http_wasm_supports_streaming_request(); fall back to buffered uploads otherwise.","Always pass a CancellationToken and treat abort-induced write failures as expected.","Avoid starting uploads you intend to cancel mid-flight when possible."],"tags":["network","http","streaming","fetch"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}