/Knowledge/sources/honojs__hono/llms-full/timeout-middleware-notes--part-02--820d0abe53bd.md
Timeout Middleware: Notes (part 02) - hono-docs
Timeout Middleware: Notes (part 02) Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt notes Summary ts a...
Timeout Middleware: Notes (part 02)
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#notes
Summary
## Content
```ts
app.get('/sse', async (c) => {
let id = 0
let running = true
let timer: number | undefined
return streamSSE(c, async (stream) => {
timer = setTimeout(() => {
console.log('Stream timeout reached, closing stream')
stream.close()
}, 3000) as unknown as number
stream.onAbort(async () => {
console.log('Client closed connection')
running = false
clearTimeout(timer)
})
while (running) {
const message = `It is ${new Date().toISOString()}`
await stream.writeSSE({
data: message,
event: 'time-update',
id: String(id++),
})
await stream.sleep(1000)
}
})
})
Metadata
{
"chunk_index": 1,
"citation": "https://hono.dev/llms-full.txt#notes",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Timeout Middleware > Notes (2)",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 350,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Timeout Middleware: Notes (part 02)",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}