MCPcopy Index your code
hub / github.com/simstudioai/sim / onData

Function onData

apps/sim/lib/core/utils/stream-limits.ts:179–201  ·  view source on GitHub ↗
(chunk: Buffer | Uint8Array | string)

Source from the content-addressed store, hash-verified

177 }
178
179 const onData = (chunk: Buffer | Uint8Array | string) => {
180 const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)
181 totalBytes += buffer.byteLength
182
183 if (totalBytes > options.maxBytes) {
184 if ('destroy' in stream && typeof stream.destroy === 'function') {
185 stream.destroy()
186 }
187 finish(() =>
188 reject(
189 new PayloadSizeLimitError({
190 label: options.label,
191 maxBytes: options.maxBytes,
192 observedBytes: totalBytes,
193 })
194 )
195 )
196 return
197 }
198
199 void options.onChunk?.(buffer, totalBytes)
200 chunks.push(buffer)
201 }
202
203 const onEnd = () => {
204 finish(() => resolve(Buffer.concat(chunks, totalBytes)))

Callers 2

readSSELinesFunction · 0.85
ServerToolsQueryFunction · 0.85

Calls 3

finishFunction · 0.70
destroyMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected