Skip to content

WebSocket close codes inconsistent across Dart versions and affected by pingInterval setting #60875

Closed
@coderabbitai

Description

@coderabbitai

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

  1. Version inconsistency: Different Dart versions return different close codes for the same scenario
  2. 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

Reported by: @nielsenko

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions