Skip to content

Spec helper: require http/web_socket for the WebSocket client - #1481

Merged
crimson-knight merged 3 commits into
v2-devfrom
spec/require-http-web-socket
Nov 26, 2026
Merged

crimson-knight merged 3 commits into
v2-devfrom
spec/require-http-web-socket

Conversation

@crimson-knight

Copy link
Copy Markdown
Member

Why

Amber's spec suite does not compile on agent-crystal 1.22.3-incremental-1 or later:

In spec/support/helpers/websockets_helper.cr:39:30
 39 | ws = HTTP::WebSocket.new("ws://127.0.0.1:#{listen_port}")
Error: expected argument #1 to 'HTTP::WebSocket.new' to be HTTP::WebSocket::Protocol or IO, not String

Since crimson-knight/crystal#45 (TLS opt-in, shipped in 1.22.3-incremental-1), the client constructor HTTP::WebSocket.new(String) lives in http/web_socket/client, and require "http" no longer loads it. A server that only accepts WebSockets no longer pulls in HTTP::Client and OpenSSL; a program that opens a WebSocket connection requires http/web_socket.

Change

spec/spec_helper.cr adds require "http/web_socket" after require "http", with a comment naming the reason. Only the spec helper changes; require "http/web_socket" exists on public Crystal too, so the suite still compiles there.

Spec run

m4-mini-02 (macOS 27.2.1, arm64), agent-crystal 1.22.3-incremental-1 (Crystal 1.22.3 (2026-11-13)), TMPDIR=/tmp crystal-alpha spec, through cluster-pool:

  • Before: the type check stops at websockets_helper.cr:39 (above).
  • After: 3243 examples, 1 failure, 2 errors, 0 pending.

The failure and both errors are in spec/amber/router/parsers/form_charset_spec.cr (lines 214, 142 and 207: the CP1252 converter spy and two "could not be decoded with its declared charset" cases). They concern form charset decoding, which the 1.22.3 fork does in Crystal (Mica) instead of iconv, and are unrelated to this change; :214 also failed in the crimson-knight/crystal#53 class check with both compilers. TMPDIR=/tmp keeps the UNIX socket listener specs' paths under macOS's 103-byte limit (in a long scratch folder they error).

AgentC and others added 3 commits November 24, 2026 22:25
The websocket helpers open clients with HTTP::WebSocket.new(String). Since
agent-crystal 1.22.3-incremental-1 (crimson-knight/crystal#45) that
constructor lives in http/web_socket/client, which require "http" no longer
loads, so the spec suite failed to compile at
spec/support/helpers/websockets_helper.cr:39.
crystal spec keeps the compiler process and its heap alive while the spec
binary runs. The fixture specs start a second compiler, and the two together
went past the medium resource class's 4 GiB, so the kernel killed the outer
compiler partway through the suite (builds 348, 349, 357). Building the
suite in its own step lets that compiler exit before any spec runs.
@crimson-knight

Copy link
Copy Markdown
Member Author

Added 9a53f9c: CircleCI now builds the spec suite in one step and runs the binary in the next. crystal spec keeps the compiler (about 2.5 GiB RSS on CircleCI) alive while the specs run, and the fixture specs start a second compiler (about 1.1 GiB). A diagnostic run (build 359) peaked at 4,214,521,856 bytes against the medium class's 4,294,967,296-byte cgroup limit; builds 348, 349 and 357 went over it, the kernel killed the outer compiler, and the orphaned spec run printed "Aborted!" at 1,366 to 1,378 of 3,258 examples. With the split, build 361 peaked at 2,471,350,272 bytes, and build 360 ran all 3,258 examples and exited about a second after the summary.

@crimson-knight
crimson-knight merged commit d6e772e into v2-dev Nov 26, 2026
8 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.

1 participant