mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 00:02:29 +00:00
* oom(01): A1-shared-readers — reintroduce #10179 subset Files: 18 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(02): A2-shared-image-media — reintroduce #10179 subset Files: 7 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(03): A3-shared-fs-listing — reintroduce #10179 subset Files: 21 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(04): A4-shared-remote-relay — reintroduce #10179 subset Files: 8 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(05): A5-shared-misc — reintroduce #10179 subset Files: 28 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(06): B-shared-wiring — reintroduce #10179 subset Files: 81 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { EventEmitter } from 'node:events'
|
|
import type { IncomingHttpHeaders, IncomingMessage } from 'node:http'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { readRequestBody } from './agent-hook-listener'
|
|
|
|
type FakeIncomingMessage = EventEmitter & {
|
|
headers: IncomingHttpHeaders
|
|
destroy: ReturnType<typeof vi.fn>
|
|
}
|
|
|
|
function createReadableRequest(): FakeIncomingMessage {
|
|
const request = new EventEmitter() as FakeIncomingMessage
|
|
request.headers = { 'content-type': 'application/json' }
|
|
request.destroy = vi.fn(() => request.emit('close'))
|
|
return request
|
|
}
|
|
|
|
describe('agent hook request body retention', () => {
|
|
it('accepts adversarial one-byte events without per-event retained buffers', async () => {
|
|
const request = createReadableRequest()
|
|
const reading = readRequestBody(request as unknown as IncomingMessage)
|
|
const value = 'x'.repeat(100_000)
|
|
const body = Buffer.from(JSON.stringify({ value }))
|
|
|
|
for (let index = 0; index < body.length; index += 1) {
|
|
request.emit('data', body.subarray(index, index + 1))
|
|
}
|
|
request.emit('end')
|
|
|
|
await expect(reading).resolves.toEqual({ value })
|
|
})
|
|
})
|