export { pumpProducerToChannel }; export type { ChannelPumpRunContext }; import type { StreamingProducer } from '../../types.js'; import type { Context } from '../../../node/server/context/context.js'; import type { RequestContext } from '../../../node/server/context/requestContext.js'; type ChannelPumpRunContext = { context: Context; requestContext: RequestContext; telefunctionName: string; telefuncFilePath: string; }; /** * Pump a single producer's chunks through a dedicated ServerChannel. * * Creates the channel, registers it, waits for client connection, then streams * chunks with proper context restoration and cleanup. * * Each binary send is tagged: `[TAG_DATA][payload]` for data, `[TAG_ERROR][errorPayload]` * for errors. Tags are defined in constants.ts and shared with the client's * ChannelStreamSource. Errors are encoded with `encodeErrorPayload` — the same * payload format as inline streaming. * * The pump races three promises each iteration: * 1. `responseAbort.errorPromise` — resolves when a sibling throws Abort * 2. `cancelledPromise` — resolves when the channel closes (client disconnect/abort) * 3. `producer.chunks.next()` — resolves when the producer yields a chunk * * `cancelledPromise` is needed because async generator `.return()` is queued behind * a pending `.next()` — it can't interrupt an in-progress `await` (e.g. `sleep()`). * Without it the pump would stay stuck until the generator's current await resolves. * * Returns the channelId for inclusion in serialized metadata. */ declare function pumpProducerToChannel(createProducer: () => StreamingProducer, runContext: ChannelPumpRunContext, onComplete?: () => void): string;