Repository navigation
feat(runtime): add waitUntil to finish background work after the response - #20
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.
Summary
Adds
context.waitUntil(promise)andawslambda.waitUntil(promise). The runtime waits for registered promises after the response is posted (plain, streaming and error paths) and before polling/invocation/next.BUN_LAMBDA_WAIT_UNTIL_MARGIN_MS(default 1000 ms). On timeout it logs a warning with the pending count and continues.console.errorand do not change the invocation result.waitUntilbehave as before.docs/how-to/wait-until.md, README and DOCS.md.Limitation
Opt-in only. A floating promise that is neither awaited nor registered is still frozen by Lambda; the runtime cannot detect it (Bun's
process.getActiveResourcesInfo()is a stub). Use@typescript-eslint/no-floating-promisesin CI.Testing
bun test: 75 pass, 10 skipped integration tests, 0 failtsc --noEmitandbun run checkcleanNot verified
No integration test was added (existing ones deploy to AWS). The timing where Lambda returns the response at POST but ends the invocation at the next
/nextcall should be confirmed on real Lambda.