Skip to content

Propagate Connection Closed Information up to top-level (fix #465) #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sebsto
Copy link
Contributor

@sebsto sebsto commented Aug 3, 2025

This PR implements a mechanism to propagate connection loss information from the Lambda runtime client to the runtime loop using EventLoopFuture, enabling termination without backtrace when the connection to the Lambda control plane (or a Mock Server) is lost.

This PR depends on changes waiting approval #542
This PR fixes #465

Changes Made
Core Changes:

  • LambdaRuntimeClient: Added futureConnectionClosed property to signal connection loss via EventLoopFuture
  • Lambda.swift: Modified runLoop to monitor connection status and throw an error on connection loss
  • LambdaRuntime and ServiceLifecycle Integration: Modified to properly handle connection loss (and other top-level) errors and avoid application to crash with a backtrace.

Termination without a backtrace

  • When connection to Lambda control plane is lost, the runtime exits cleanly
  • Prevents hanging or zombie processes in testing/development environments
  • Maintains compatibility with AWS Lambda service behavior (new runtime environment creation)

Use Cases

  • Performance Testing: Prevents hanging when testing against MockServer
  • Development: Cleaner shutdown behavior during local testing
  • Production: Aligns with AWS Lambda service expectations for connection loss scenarios

@sebsto sebsto added this to the 2.0 milestone Aug 3, 2025
@sebsto sebsto self-assigned this Aug 3, 2025
@sebsto sebsto added the 🆕 semver/minor Adds new public API. label Aug 3, 2025
@sebsto sebsto changed the title Propagate Connection Closed Information Through Future, up to top-level [WIP] Propagate Connection Closed Information Through Future, up to top-level Aug 3, 2025
@sebsto sebsto marked this pull request as draft August 3, 2025 17:44
@sebsto sebsto changed the title [WIP] Propagate Connection Closed Information Through Future, up to top-level [WIP] Propagate Connection Closed Information up to top-level Aug 3, 2025
@sebsto sebsto changed the title [WIP] Propagate Connection Closed Information up to top-level Propagate Connection Closed Information up to top-level Aug 3, 2025
@sebsto sebsto requested a review from adam-fowler August 3, 2025 18:12
@sebsto sebsto marked this pull request as ready for review August 3, 2025 18:13
@sebsto sebsto changed the title Propagate Connection Closed Information up to top-level Propagate Connection Closed Information up to top-level (fix #465) Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] LambdaRuntimeClient do nothing when server closes the connection
1 participant