feat(lambda): durable function callbacks (#5100)

* feat(lambda): durable function callbacks

A CALLBACK operation started at checkpoint gets a callback id that
SendDurableExecutionCallbackSuccess, Failure and Heartbeat complete or
keep alive, after which the function is invoked again to see it.
TimeoutSeconds and HeartbeatTimeoutSeconds time it out with
Callback.Timeout or Callback.Heartbeat. A completed, timed out or
stopped callback answers CallbackTimeoutException, an unreadable id
"Invalid callback id". The callback id carries the execution ARN, which
IAM authorizes the callback actions against.

Option range errors now name the update, as AWS does
("updates.1.member.waitOptions.waitSeconds").

* fix(lambda): name a repeated durable update as AWS does

AWS rejects two updates of one operation in a batch, other than a START
closed by its STEP or CONTEXT action, with "Cannot update the same
operation twice in a single request."

* fix(lambda): leave a durable execution waiting after a body-less callback failure

AWS marks a callback failed with an empty request body as FAILED but does
not invoke the function again, so the execution keeps waiting. The SDKs
send {} when Error is omitted, which does invoke it.

* fix(lambda): bound a durable callback failure's error at 1 MB

AWS rejects an Error over 1048576 bytes, measured as compact JSON, with
InvalidParameterValueException "Error object size must be less than or
equal to 1048576 bytes."

* test(lambda): keep a pending durable callback across a restart

* fix(lambda): reject a durable callback failure body that is not a JSON object

AWS treats only an empty body as a failure with no Error. Whitespace,
null or broken JSON get 400 SerializationException and leave the
callback open.

* docs(lambda): note the durable callback result limit AWS enforces
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-10-05 10:27:50 -04:00
1 parent a6df1dbb12
commit a1ed65c51d
20 files changed
+809 -50

No files matched your search

+16 -5
View File
@@ -61,6 +61,9 @@ Floci Lambda runs your function code locally inside real Docker containers - clo
| `GetDurableExecutionHistory` | Event log of a durable execution, oldest or newest first |
| `ListDurableExecutionsByFunction` | Durable executions of a function or version, filtered by status, name and start time |
| `StopDurableExecution` | Stop a running durable execution with an error |
| `SendDurableExecutionCallbackSuccess` | Complete a durable callback with a result, up to 1 MB |
| `SendDurableExecutionCallbackFailure` | Fail a durable callback with an error |
| `SendDurableExecutionCallbackHeartbeat` | Keep a durable callback with a heartbeat timeout alive |
`UpdateFunctionConfiguration` validates `MemorySize` and `Timeout` as whole numbers in their
supported ranges before changing any stored settings. A rejected value returns
@@ -165,24 +168,33 @@ background. Invocations through an ARN (EventBridge, Scheduler, function URLs, d
durable executions the same way.
The checkpoint protocol under `/2025-12-01` is the real one, so the Durable Execution SDK works
unchanged for steps, waits, step retries and replay. Timers are persisted and fired by a
unchanged for steps, waits, step retries, callbacks and replay. Timers are persisted and fired by a
background sweep, so an execution survives a restart of Floci. A function that returns something
other than the `{Status, Result, Error}` envelope fails its execution with
`Invalid Status in invocation output.` A function that throws is re-invoked four more times, after
1, 2, 4 and 8 seconds, and then fails the execution with its error. AWS does the same over a few
minutes.
A callback (`createCallback`, `waitForCallback`) gets a callback id that the
`SendDurableExecutionCallback*` APIs complete. Its `TimeoutSeconds` and `HeartbeatTimeoutSeconds`
fail it with `Callback.Timeout` or `Callback.Heartbeat`, and each heartbeat restarts the heartbeat
timeout. A failure sent with an empty request body fails the callback but does not invoke the
function again, as on AWS, so the execution keeps waiting. The SDKs send `{}` when `Error` is
omitted, which does invoke it.
`GetDurableExecutionHistory` leaves payloads out unless `IncludeExecutionData=true` is sent. The
API reference names `true` as the default, but AWS answers this way.
`SendDurableExecutionCallbackSuccess` takes a result of up to 1 MB. The API reference names 256 KB,
but AWS accepts 1 MB and rejects one byte more.
The public `public.ecr.aws/lambda` images do not bundle the SDK that the managed runtimes carry.
Add `aws-durable-execution-sdk-python` or `@aws/durable-execution-sdk-js` to your deployment
package.
Not emulated yet:
- Callbacks (`WaitForCallback` and the `SendDurableExecutionCallback*` APIs) and chained invokes
(`context.invoke`). Both are rejected at checkpoint time.
- Chained invokes (`context.invoke`). They are rejected at checkpoint time.
- Durable executions started by Step Functions or by an event source mapping. These invoke the
function as a plain one.
- Payload encryption. `KMSKeyArn` is stored and returned only.
@@ -387,8 +399,7 @@ These AWS Lambda operations have no handler in Floci. Calls will return `404` or
- Layer permissions (`AddLayerVersionPermission`, `RemoveLayerVersionPermission`, `GetLayerVersionPolicy`)
- Provisioned concurrency (`PutProvisionedConcurrencyConfig`, `GetProvisionedConcurrencyConfig`, `ListProvisionedConcurrencyConfigs`, `DeleteProvisionedConcurrencyConfig`)
- `InvokeWithResponseStream`
- Durable function callbacks and chained invokes (`SendDurableExecutionCallbackSuccess`,
`SendDurableExecutionCallbackFailure`, `SendDurableExecutionCallbackHeartbeat`). See Durable Functions
- Durable function chained invokes. See Durable Functions
- Code signing enforcement. A configuration is created, read, updated, deleted and listed, and
nothing verifies a signature against it, so it never gates a deployment. Attaching one to a
function is not wired either: there is no `PutFunctionCodeSigningConfig`, so