docs(examples): await createCallback before destructuring in TypeScript serialization example#203
Conversation
yaythomas
left a comment
There was a problem hiding this comment.
Verification (source-confirmed)
createCallback is declared as returning DurablePromise<CreateCallbackResult> (types/durable-context.ts:345,364; impl context/durable-context/durable-context.ts:464). It resolves to the [promise, callbackId] tuple — it does not return the tuple synchronously.
The SDK's own JSDoc examples both await it before destructuring (types/durable-context.ts:333 and :357: const [callbackPromise, callbackId] = await context.createCallback(...)).
Without await, the code destructures the DurablePromise object, which is not iterable as a 2-tuple, so approval and callbackId would both be undefined. The subsequent console.log(callbackId) would log undefined and await approval would await undefined. The original example was functionally broken; the fix is correct.
The enclosing handler is async, so await is valid here.
Issue
The TypeScript callback-serdes example embedded in
docs/sdk-reference/state/serialization.mddestructures the result ofcontext.createCallback()withoutawait:
ts const [approval, callbackId] = context.createCallback("await-approval", { serdes: approvalSerdes, }); Correct way:
createCallback method signature

Description of changes: