Skip to content

Conversation

@nielsenko
Copy link
Collaborator

@nielsenko nielsenko commented Jan 16, 2026

Description

Adds a force parameter (default: false) to the close() method that allows immediate shutdown with forceful termination of in-flight requests.

  • When force: false (default): waits for in-flight requests to complete before closing
  • When force: true: immediately closes and forcefully terminates remaining connections
  • Propagates through Adapter, IOAdapter, and all RelicServer implementations
  • Enables custom timeout logic for predictable shutdown timing

Example usage:

await Future.any([
  server.close(),
  Future.delayed(Duration(seconds: 30)).then((_) => server.close(force: true))
]);

Related Issues

Pre-Launch Checklist

  • This update focuses on a single feature or bug fix.
  • I have read and followed the Dart Style Guide and formatted the code using dart format.
  • I have referenced at least one issue this PR fixes or is related to.
  • I have updated/added relevant documentation (doc comments with ///), ensuring consistency with existing project documentation.
  • I have added new tests to verify the changes.
  • All existing and new tests pass successfully.
  • I have documented any breaking changes below.

Breaking Changes

  • Includes breaking changes.
  • No breaking changes.

Additional Notes

The force parameter maps directly to Dart's HttpServer.close(force:) parameter. This is useful for self-hosted deployments where container orchestration behavior may vary, or when long-running requests should not delay server shutdown indefinitely.

Summary by CodeRabbit

  • New Features

    • Added optional force parameter to server shutdown, enabling immediate termination of all in-flight requests instead of waiting for graceful completion.
  • Tests

    • Added test to verify force shutdown behavior correctly terminates active requests.

✏️ Tip: You can customize this high-level summary in your review settings.

Add a force parameter (default: false) to the close() method that allows
immediate shutdown with forceful termination of in-flight requests.

When force is false (default), the server waits for in-flight requests
to complete before closing. When force is true, the server immediately
closes and forcefully terminates remaining connections.
@nielsenko nielsenko self-assigned this Jan 16, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This PR adds a force parameter to the close() method across the server infrastructure, enabling immediate shutdown when force=true while maintaining backward-compatible graceful shutdown by default. The parameter is threaded through the Adapter and RelicServer implementations and verified with a new test.

Changes

Cohort / File(s) Summary
Core API Signatures
packages/relic_core/lib/src/adapter/adapter.dart, packages/relic_core/lib/src/relic_server.dart, packages/relic_io/lib/src/adapter/io_adapter.dart
Updated close() method signatures to accept optional named parameter force (default: false). RelicServer and its implementations (_RelicServer, _IsolatedRelicServer, _MultiIsolateRelicServer) forward the parameter through the call chain to the Adapter. IOAdapter propagates the parameter to the underlying HTTP server.
Test Updates
packages/relic/test/router/relic_app_test.dart
Updated _FakeAdapter.close() mock signature to accept the force parameter for test compatibility.
New Test
packages/relic/test/relic_server_graceful_shutdown_test.dart
Added test verifying that server.close(force: true) immediately terminates in-flight requests, throwing a ParallelWaitError with corresponding AsyncError entries.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a force parameter to the server close() method.
Description check ✅ Passed The description includes all required template sections: clear description of changes, linked issue (#294), completed pre-launch checklist, and breaking changes documentation.
Linked Issues check ✅ Passed All coding requirements from issue #294 are met: force parameter added with default false, signature propagated through Adapter/IOAdapter/RelicServer implementations, graceful close preserved, forced termination implemented, and new test added.
Out of Scope Changes check ✅ Passed All changes are directly within scope of adding the force parameter to close() method. No unrelated modifications to other features or functionality are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nielsenko
Copy link
Collaborator Author

@CodeRabbit review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.95%. Comparing base (4026b89) to head (a72e210).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/relic_core/lib/src/relic_server.dart 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #317   +/-   ##
=======================================
  Coverage   27.95%   27.95%           
=======================================
  Files          87       87           
  Lines        3291     3291           
  Branches     1735     1735           
=======================================
  Hits          920      920           
  Misses       2371     2371           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@marcelomendoncasoares marcelomendoncasoares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@nielsenko nielsenko merged commit 196eef7 into serverpod:main Jan 16, 2026
53 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add force parameter to close method for immediate shutdown

2 participants