Skip to content

docs(examples): await createCallback before destructuring in TypeScript serialization example#203

Merged
yaythomas merged 1 commit into
aws:mainfrom
TrickSumo:patch-6
Jun 13, 2026
Merged

docs(examples): await createCallback before destructuring in TypeScript serialization example#203
yaythomas merged 1 commit into
aws:mainfrom
TrickSumo:patch-6

Conversation

@TrickSumo

@TrickSumo TrickSumo commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Issue

The TypeScript callback-serdes example embedded in docs/sdk-reference/state/serialization.md destructures the result of context.createCallback() without await:

ts const [approval, callbackId] = context.createCallback("await-approval", { serdes: approvalSerdes, }); ​

Correct way:

createCallback method signature
image

Description of changes:

  • Used await before createCallback()

@yaythomas yaythomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yaythomas yaythomas merged commit a442974 into aws:main Jun 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants