Closed
Description
Summary
WebSocket close codes are inconsistent across different Dart versions and unexpectedly affected by the pingInterval
setting when the connection is closed abnormally (e.g., by killing the server process).
Expected Behavior
When a WebSocket connection is closed abnormally (server process killed), the close code should consistently be 1006 (Abnormal) across all Dart versions, regardless of whether pingInterval
is set.
Actual Behavior
With pingInterval
set client-side:
- Dart 3.5.0, 3.6.2, 3.8.1: Returns 1001 (Going away)
Without pingInterval
set client-side:
- Dart 3.7.2: Returns 1005 (No status)
- Dart 3.8.1: Returns 1006 (Abnormal)
Issues
- Version inconsistency: Different Dart versions return different close codes for the same scenario
- Unexpected pingInterval effect: Setting
pingInterval
client-side changes the close code behavior, which seems unrelated to the close code logic
Context
This issue was discovered while writing tests for WebSocket behavior where the server process is terminated abruptly. The inconsistent behavior makes it difficult to write reliable tests that work across different Dart versions.
Backlinks
- Original PR: refactor!: Replace DuplexStreamChannel with RelicWebSocket serverpod/relic#91
- Comment discussion: refactor!: Replace DuplexStreamChannel with RelicWebSocket serverpod/relic#91 (comment)
Reported by: @nielsenko
Metadata
Metadata
Assignees
Labels
No labels