Repository navigation
Add connectTimeout support to Options class - #2464
Conversation
- Added connectTimeout parameter to Options constructor - Added connectTimeout field with getter/setter validation - Updated Options.copyWith to support connectTimeout - Updated Options.compose to merge connectTimeout from Options with BaseOptions - Added comprehensive tests for connectTimeout functionality Co-authored-by: AlexV525 <[email protected]>
- Remove unused variable in test - Apply dart format to ensure consistent formatting Co-authored-by: AlexV525 <[email protected]>
|
@copilot Added connectTimeout also needs to be used in applicable adapters as for real-world usages. |
…adapter - Added test showing Options.connectTimeout overrides BaseOptions.connectTimeout - Test verifies the adapter uses the Options timeout (100ms) not BaseOptions (30s) - Test validates compose behavior for connectTimeout merging Co-authored-by: AlexV525 <[email protected]>
All adapters (IOHttpClientAdapter, BrowserHttpClientAdapter, Http2Adapter, and native adapters) already use I've added an integration test (commit 5ecfad9) that demonstrates the feature working end-to-end with the adapter. The test shows that Options.connectTimeout (100ms) correctly overrides BaseOptions.connectTimeout (30s), with the request timing out in ~126ms as expected. |
- Clean up test output by removing debug print statements - Test still validates behavior correctly Co-authored-by: AlexV525 <[email protected]>
|
@copilot Also check if |
- Renamed test file from options_connect_timeout_integration_test to options_timeout_integration_test - Added tests demonstrating Options.sendTimeout overrides BaseOptions.sendTimeout - Added tests demonstrating Options.receiveTimeout overrides BaseOptions.receiveTimeout - Added test showing all three timeout types can be set simultaneously via Options - All timeout types (connectTimeout, sendTimeout, receiveTimeout) now have consistent test coverage Co-authored-by: AlexV525 <[email protected]>
Checked and verified.
All tests pass, confirming the feature works uniformly across all timeout types. |
Enables per-request connection timeout override via
Options, matching existingsendTimeout/receiveTimeoutpattern.Changes
Optionsclass: AddedconnectTimeoutparameter with validation (constructor, getter/setter,copyWith())Options.compose()now mergesconnectTimeoutwithOptionstaking precedence overBaseOptionsoptions_test.dart,connect_timeout_integration_test.dart, andoptions_timeout_integration_test.dartconnectTimeout,sendTimeout,receiveTimeout) work consistently when set viaOptions, validating that they correctly overrideBaseOptionsvalues in real-world usageAdapter Support
All adapters (IOHttpClientAdapter, BrowserHttpClientAdapter, Http2Adapter, and native adapters) already use timeout values from RequestOptions. The adapters automatically pick up all timeout values from
RequestOptions, which is populated byOptions.compose(). No adapter code changes were needed.Usage
New Pull Request Checklist
mainbranch to avoid conflicts (via merge from master or rebase)CHANGELOG.mdin the corresponding packageAdditional context and info (if any)
Implementation follows existing timeout field patterns. Maintains backward compatibility with no breaking changes.
Integration tests validate that all timeout types (
connectTimeout,sendTimeout,receiveTimeout) work consistently with actual adapters in real-world scenarios. Tests confirm that Options values correctly override BaseOptions values for all three timeout types.Fixes #2454
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.