MCPcopy
hub / github.com/simstudioai/sim / start

Function start

apps/sim/lib/core/security/input-validation.server.ts:576–605  ·  view source on GitHub ↗
(controller)

Source from the content-addressed store, hash-verified

574 const nodeRes = res
575 const body = new ReadableStream<Uint8Array>({
576 start(controller) {
577 nodeRes.on('data', (chunk: Buffer) => {
578 totalBytes += chunk.length
579 if (
580 typeof maxResponseBytes === 'number' &&
581 maxResponseBytes > 0 &&
582 totalBytes > maxResponseBytes
583 ) {
584 cleanupAbort()
585 controller.error(
586 new PayloadSizeLimitError({
587 label: 'response body',
588 maxBytes: maxResponseBytes,
589 observedBytes: totalBytes,
590 })
591 )
592 nodeRes.destroy()
593 return
594 }
595 controller.enqueue(new Uint8Array(chunk))
596 })
597 nodeRes.on('end', () => {
598 cleanupAbort()
599 controller.close()
600 })
601 nodeRes.on('error', (err) => {
602 cleanupAbort()
603 controller.error(err)
604 })
605 },
606 cancel() {
607 cleanupAbort()
608 nodeRes.destroy()

Callers

nothing calls this directly

Calls 6

cleanupAbortFunction · 0.85
onMethod · 0.80
errorMethod · 0.80
destroyMethod · 0.65
enqueueMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected