feat(serverless-offline-sqs): opt-in autoStart ElasticMQ for self-contained operation (Fixes #146)#296
Merged
Merged
Conversation
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.
Fixes #146
What / why
Adds opt-in self-contained operation to
serverless-offline-sqs: withautoStart: truethe plugin spawns an ElasticMQ container from its own lifecycle, points the SQS client at it, and tears it down on stop/SIGINT — so you no longer have to stand up ElasticMQ yourself. Paired withautoCreate: trueit's a true zero-setup local SQS:Default is OFF — with
autoStartunset, behavior is byte-for-byte identical to today (no Docker invocation, no endpoint mutation).Design decision: Docker-managed, not a vendored pure-JS emulator
The earlier discussion leaned toward bundling a pure-JS SQS server. I went with Docker-managed
softwaremill/elasticmq-nativeinstead, because the only credible JS option (sqslite) is unmaintained (last publish 2022, Fastify v3 EOL) and — critically — does not implement FIFO semantics, which would silently diverge from the FIFO (#189) and DLQ-ordering (#167) work this repo validates against ElasticMQ. Docker-managed reuses the exact engine the whole test suite already targets, so there's zero behavioral drift.Honest caveat (also noted on the issue): this is "self-contained given Docker", not zero-runtime — true JVM-free bundling isn't possible without an incomplete emulator. Docker is the smallest reliable common denominator for this codebase (every integration test is already docker-compose-based).
sqsliteremains a possible futureengine:opt-in for Docker-less, non-FIFO users.Safety / lifecycle
endpointalways wins (autoStart skipped + warned).offline:start:endand SIGINT/SIGTERM;stop()is idempotent.--rm+ fixed--nameso a leaked container (hard crash) is reclaimed on the next start; and if a laterstart()step throws after the container is up, it's torn down immediately (no single-session leak).child_processCLI, readiness via built-infetch.Credit
Thanks @tstackhouse for the well-framed proposal and @tristan-mastrodicasa for the +1.
Verification
npx ava→ 175 unit tests pass (149 pre-existing untouched + 26 new #146),npx eslintclean, zero new runtime deps. The real Docker integration test ran green (Docker 29, ~6.4s): container boots, both an event-wired and a resource-only queue autoCreate inside it, a message round-trips,end()removes the container,docker ps -ashows no leftover. Independently re-run by the orchestrator after a mid-start-leak hardening commit.🤖 Generated with Claude Code