Closed bogeychan closed 3 months ago
1.1.2
WSL Ubuntu
// test.test.ts import { describe, it, expect } from 'bun:test' import { req } from '../utils' import { Elysia } from '../../src' describe('Stream', () => { it('handle stream with headers', async () => { const app = new Elysia().get('/', async function* (ctx) { await Bun.sleep(1_000) ctx.set.headers['another'] = 'header' yield 'a' }) const response = await app.handle(req('/')) expect(response.headers.get('another')).toBe('header') }) })
test pass
test fail
related to https://github.com/elysiajs/elysia/issues/727
to fix this you have to await the first generator result but the handleStream function is not async...
await
handleStream
async
https://github.com/elysiajs/elysia/blob/3b3fbcd5abae6778965cb1b10a3a7a8d804cacf2/src/handler.ts#L121
const { value } = await generator.next() // set headers here return new Response(..., set)
Should have been fixed with https://github.com/elysiajs/elysia/commit/20431a290e1a1339a380253e3c10a068f4a131b1, published under 1.1.3
Thanks, works for me
What version of Elysia.JS is running?
1.1.2
What platform is your computer?
WSL Ubuntu
What steps can reproduce the bug?
What is the expected behavior?
test pass
What do you see instead?
test fail
Additional information
related to https://github.com/elysiajs/elysia/issues/727
to fix this you have to
await
the first generator result but thehandleStream
function is notasync
...https://github.com/elysiajs/elysia/blob/3b3fbcd5abae6778965cb1b10a3a7a8d804cacf2/src/handler.ts#L121