Skip to content

docs(maintenance): explain how to test invocation-scoped state - #5661

Merged
svozza merged 4 commits into
mainfrom
docs/5619-invoke-store-testing
Sep 7, 2026
Merged

svozza merged 4 commits into
mainfrom
docs/5619-invoke-store-testing

Conversation

@svozza

@svozza svozza commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Documents why the concurrency tests in Logger, Metrics, and Batch reset the InvokeStore in beforeEach, why sequence() is enough inside invocation callbacks, and why code that runs before sequence() must call getInstanceAsync() after stubbing AWS_LAMBDA_MAX_CONCURRENCY. None of this was written down anywhere in the repo and had to be re-derived from the @aws/lambda-invoke-store source while reviewing #5615.

Changes

  • Add an "Invocation-scoped state" group to the Unit tests section of CODING_STANDARDS.md, covering the lazy publication of globalThis.awslambda.InvokeStore, the module-level instance cache whose kind is fixed on first creation, the reset() and getInstanceAsync() ordering rule with a minimal example, the silent failure mode when the order is wrong, and the vi.stubGlobal('awslambda', undefined) / vi.unstubAllGlobals() pairing used by the InvokeStore is not available tests.
  • Link @aws/lambda-invoke-store to its npm page.
  • Add a paragraph to the sequence() JSDoc in packages/testing/src/helpers.ts stating that it calls getInstanceAsync() itself and pointing pre-sequence() code at the standards doc.
  • Add a comment above AWS_LAMBDA_BENCHMARK_MODE in packages/testing/src/setupEnv.ts explaining that it exposes InvokeStore._testing.reset().
  • Notes for reviewers: docs and comments only, no behaviour change. Reviewed with Codex against the invoke-store source and the existing concurrency tests; its three wording findings are applied in the last commit.

Issue number: closes #5619


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

Documents in CODING_STANDARDS.md why concurrency tests reset the
InvokeStore in beforeEach, why sequence() suffices inside invocation
callbacks, and why code that runs before it must call getInstanceAsync()
after stubbing AWS_LAMBDA_MAX_CONCURRENCY. Adds pointers from the
sequence() JSDoc and the AWS_LAMBDA_BENCHMARK_MODE line in setupEnv.

Closes #5619
Applies wording fixes from review: drops the getInstanceAsync(true)
escape hatch, narrows the throw claim to invocation-scoped reads and
writes, and shortens the sentences.
@svozza
svozza merged commit d672ee4 into main Sep 7, 2026
43 checks passed
@svozza
svozza deleted the docs/5619-invoke-store-testing branch September 7, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR between 10-29 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance: document how to test invocation-scoped state with the InvokeStore

2 participants