/Knowledge/sources/honojs__hono/llms-full/streaming-helper-error-handling--914f782659b8.md
Streaming Helper: Error Handling - hono-docs
Streaming Helper: Error Handling Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt error handling Summar...
Streaming Helper: Error Handling
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#error-handling
Summary
The third argument of the streaming helper is an error handler. This argument is optional, if you don't specify it, the error will be output as a console error. ```ts app.get('/stream', (c) => { return stream( c, async (stream) => { // W...
Content
The third argument of the streaming helper is an error handler. This argument is optional, if you don't specify it, the error will be output as a console error.
app.get('/stream', (c) => {
return stream(
c,
async (stream) => {
// Write a process to be executed when aborted.
stream.onAbort(() => {
console.log('Aborted!')
})
// Write a Uint8Array.
await stream.write(
new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f])
)
// Pipe a readable stream.
await stream.pipe(anotherReadableStream)
},
(err, stream) => {
stream.writeln('An error occurred!')
console.error(err)
}
)
})
The stream will be automatically closed after the callbacks are executed.
::: warning
If the callback function of the streaming helper throws an error, the onError event of Hono will not be triggered.
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#error-handling",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Streaming Helper > Error Handling (1)",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 677,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Streaming Helper: Error Handling",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}