Skip to content

feat(serverless-offline): Lambda async destinations (onFailure/onSuccess) for eventbridge, sqs & ddb-streams#294

Merged
silouone merged 1 commit into
masterfrom
feat/lambda-async-destinations
Jun 21, 2026
Merged

feat(serverless-offline): Lambda async destinations (onFailure/onSuccess) for eventbridge, sqs & ddb-streams#294
silouone merged 1 commit into
masterfrom
feat/lambda-async-destinations

Conversation

@silouone

Copy link
Copy Markdown
Member

What / why

Roadmap P3 — Lambda async-invoke destinations parity (onFailure/onSuccess) for the offline event sources. serverless-offline-eventbridge already had a single-target _onFailure; this generalises it into a small per-package src/destinations.js helper (the 3 copies are byte-identical) and wires it into serverless-offline-sqs (poll-loop retry exhaustion) and serverless-offline-dynamodb-streams (handler-retry exhaustion), so all three event sources honour the same destinations contract: on exhausted retries dispatch {requestPayload, responsePayload:{errorMessage, errorType}} to the target SQS queue, and on a clean run dispatch the onSuccess record. Gated behind simulateDestinations !== false; every dispatch error is log.warning-ed, never thrown.

Design decision — no cross-package coupling

This monorepo has no shared internal package, and a prior cross-package runtime deep-import was contentious. So the helper is duplicated per package (identical src/destinations.js, same MD5) rather than deep-imported — modest duplication in exchange for zero new inter-package runtime coupling. Flagging for your call; happy to switch to a shared module if you'd prefer.

ARN resolution (EARS6)

The destination ARN resolves through the same path the event-source ARNs use (resolveCfnValue + a resolveQueueRefArn mirroring index.resolveSqsRefArn): literal ARN, {arn}, Ref/Fn::GetAtt-Arn to a stack-declared AWS::SQS::Queue, Fn::Sub/Fn::Join, and AWS::Region/AWS::AccountId pseudo-params. Cross-stack Fn::ImportValue and refs to non-queue/absent resources are unresolvable offline → warn + skip (documented limit, not a hidden gap).

Verification

npx ava across all three suites → 299 passed (eventbridge 76, sqs 142, ddb 81; +8 new EARS6 tests), npx eslint clean on all changed files. Test-first proven (new destinations.js absent on master ⇒ the new tests fail to load on base). New @aws-sdk/client-sqs ^3.0.0 runtime dep added to dynamodb-streams (matches sqs/eventbridge). Independently re-run by the orchestrator: green. Unit-level only — SQS client stubbed, no docker.

Note on merge ordering

Touches serverless-offline-sqs/src/sqs.js and serverless-offline-dynamodb-streams/src/dynamodb-streams.js, so it overlaps the resilience-polish branch (B1) and the in-flight #291/#292 area — straightforward to rebase, just merge in a deliberate order.

🤖 Generated with Claude Code

@silouone silouone marked this pull request as ready for review June 21, 2026 12:00
@silouone silouone self-assigned this Jun 21, 2026
…ess) for eventbridge, sqs & ddb-streams

Shared per-package destinations.js helper; Ref/Fn::GetAtt ARN resolution; onSuccess; reused in sqs + ddb-streams.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@silouone silouone force-pushed the feat/lambda-async-destinations branch from 7cb7b50 to 62139cf Compare June 21, 2026 12:12
@silouone silouone merged commit 3eeb1de into master Jun 21, 2026
2 checks 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.

1 participant