rails/rails · error · ArgumentError
Failed to execute 'close' on WebSocket: The code must be eit
Error message
Failed to execute 'close' on WebSocket: The code must be either 1000, or between 3000 and 4999. #{code} is neither. What it means
Error "Failed to execute 'close' on WebSocket: The code must be either 1000, or between 3000 and 4999. #{code} is neither." thrown in rails/rails.
Source
Thrown at actioncable/lib/action_cable/server/socket/client_socket.rb:96
emit_error e.message
end
def transmit(message)
return false if @ready_state > OPEN
case message
when Numeric then @driver.text(message.to_s)
when String then @driver.text(message)
when Array then @driver.binary(message)
else false
end
end
def close(code = nil, reason = nil)
code ||= 1000
reason ||= ""
unless code == 1000 || (code >= 3000 && code <= 4999)
raise ArgumentError, "Failed to execute 'close' on WebSocket: " \
"The code must be either 1000, or between 3000 and 4999. " \
"#{code} is neither."
end
@ready_state = CLOSING unless @ready_state == CLOSED
@driver.close(reason, code)
end
def parse(data)
@driver.parse(data)
end
def client_gone
finalize_close
end
def alive?
@ready_state == OPENView on GitHub (pinned to 817fc2a147)
When it happens
Trigger: Thrown at actioncable/lib/action_cable/server/socket/client_socket.rb:96 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rails/rails@817fc2a147 (2026-08-04).
Data as JSON: /data/errors/30b51e3b8e2e6e7f.json.
Report an issue: GitHub.