feat(serverless-offline): Lambda async destinations (onFailure/onSuccess) for eventbridge, sqs & ddb-streams#294
Merged
Conversation
…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>
7cb7b50 to
62139cf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
Roadmap P3 — Lambda async-invoke destinations parity (
onFailure/onSuccess) for the offline event sources.serverless-offline-eventbridgealready had a single-target_onFailure; this generalises it into a small per-packagesrc/destinations.jshelper (the 3 copies are byte-identical) and wires it intoserverless-offline-sqs(poll-loop retry exhaustion) andserverless-offline-dynamodb-streams(handler-retry exhaustion), so all three event sources honour the samedestinationscontract: on exhausted retries dispatch{requestPayload, responsePayload:{errorMessage, errorType}}to the target SQS queue, and on a clean run dispatch theonSuccessrecord. Gated behindsimulateDestinations !== false; every dispatch error islog.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+ aresolveQueueRefArnmirroringindex.resolveSqsRefArn): literal ARN,{arn},Ref/Fn::GetAtt-Arnto a stack-declaredAWS::SQS::Queue,Fn::Sub/Fn::Join, andAWS::Region/AWS::AccountIdpseudo-params. Cross-stackFn::ImportValueand refs to non-queue/absent resources are unresolvable offline → warn + skip (documented limit, not a hidden gap).Verification
npx avaacross all three suites → 299 passed (eventbridge 76, sqs 142, ddb 81; +8 new EARS6 tests),npx eslintclean on all changed files. Test-first proven (newdestinations.jsabsent on master ⇒ the new tests fail to load on base). New@aws-sdk/client-sqs ^3.0.0runtime 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.jsandserverless-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