-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Feature Request
Add a force parameter to the server's close() method to allow immediate shutdown that forcefully terminates in-flight requests.
Motivation
Currently, in-flight requests can potentially keep the server alive indefinitely during shutdown. While this may not be an issue in environments like Serverpod Cloud (where containers are force-terminated after a timeout), having a force parameter would make the API more complete and give users better control over shutdown behavior.
Proposed Solution
Add a force parameter (default: false) to the close() method that:
- When
false(default): Waits for in-flight requests to complete (current behavior) - When
true: Immediately closes the server and forcefully terminates remaining connections
This approach allows users to implement their own timeout logic if needed:
// Example: Close with a 30-second timeout
Future.any([
server.close(),
Future.delayed(Duration(seconds: 30)).then((_) => server.close(force: true))
]);Use Case
This is particularly useful for:
- Self-hosted deployments where container orchestration behavior may vary
- Scenarios where long-running requests should not delay server shutdown indefinitely
- Production environments requiring predictable shutdown timing
- Custom timeout implementations based on specific application needs
Context
This enhancement was suggested during testing of graceful shutdown behavior in PR #292, which verified that in-flight requests complete successfully during shutdown.
Related
Metadata
Metadata
Labels
Type
Projects
Status