Skip to content

fix: Format streaming_data_source.dart to comply with 80-character li…

ddf87fc
Select commit
Loading
Failed to load commit list.
Closed

feat: Add ping and poll pattern support for Relay Proxy compatibility #234

fix: Format streaming_data_source.dart to comply with 80-character li…
ddf87fc
Select commit
Loading
Failed to load commit list.
Cursor / Cursor Bugbot completed Nov 4, 2025 in 2m 50s

Bugbot Review

Bugbot Analysis Progress (3m 5s elapsed)

✅ Gathered PR context (15s)
✅ Analyzed code changes (1s)
✅ Completed bug detection — 2 potential bugs found (1m 26s)
✅ Validation and filtering completed (0s)
✅ Posted analysis results — 2 bugs reported (1m 23s)
✅ Analysis completed successfully (0s)

Final Result: Bugbot completed review and found 2 potential issues

Request ID: serverGenReqId_c16e008c-1b3b-4d86-a0b4-d5f02220ee0f

Details

Bug: Incorrect Delay Calculation Neglects Elapsed Time

Incorrect delay calculation: The max() function compares (_pollingInterval.inMilliseconds - timeSincePoll.inMilliseconds) with _pollingInterval.inMilliseconds. Since timeSincePoll is always positive (time elapsed during the poll), the first argument will always be less than the second, so max() will always return _pollingInterval.inMilliseconds. This means the delay will always be the full polling interval, completely ignoring the time already spent polling. The correct logic should use max(0, _pollingInterval.inMilliseconds - timeSincePoll.inMilliseconds) to ensure the delay is never negative while properly accounting for elapsed time.

packages/common_client/lib/src/data_sources/polling_data_source.dart#L168-L171

// we want to poll after 25 seconds.
final delay = Duration(
milliseconds: max(
_pollingInterval.inMilliseconds - timeSincePoll.inMilliseconds,

Fix in Cursor Fix in Web


Bug: Resource leak: close HTTP client on stop requested

Resource leak: The HTTP client _client is never closed when the polling data source stops. Unlike the streaming data source which properly closes _pollingClient in its stop() method (line 158 in streaming_data_source.dart), the polling data source's stop() method doesn't close the client, leading to a resource leak. The stop() method should call _client.close() to properly clean up resources.

packages/common_client/lib/src/data_sources/polling_data_source.dart#L188-L193

void restart() {
// For polling there is no persistent connection, so this function
// has no effect.
}
@override

Fix in Cursor Fix in Web