Skip to main content

toSseFrame

@forge/monorepo


@forge/monorepo / backend/src / toSseFrame

Function: toSseFrame()

toSseFrame(event): string

Defined in: backend/src/graphql/sse.ts:40

Encode one event as a graphql-sse next frame.

docs/extraction/twenty-sdk-comparison.md records the decision: "Match the graphql-sse framing rather than inventing a bespoke SSE protocol" — twenty-sdk already streams GraphQL over graphql-sse, so a client can consume this unmodified. This previously emitted event: <RunEvent.type> with a raw RunEvent as data, which no graphql-sse client understands.

The id: line keeps carrying RunEvent.sequence, which is what makes Last-Event-ID resume work.

A failed run is a next frame, not an error frame, and that is deliberate. run.failed is a durable event with a sequence, sitting in the log like any other. Delivering it as a protocol-level error would leave it with no id: — so Last-Event-ID could not resume past it, and a reconnecting client would never learn the run ended. An ExecutionResult may carry both data and errors, so the event travels in data and the platform error in errors: clients surface it through their normal error path (which is what AC-3 is for) and resume keeps working.

Parameters

event

RunEvent

Returns

string