Skip to content

TypeError in SSEClient#close from paren-less is_a? call (8.11.0) #623

@dan98765

Description

@dan98765

Description

Version 8.11.0 introduced a TypeError: class or module required in SSEClient#close that fires on every SSE socket close. The error is caught by the rescue StandardError block so it doesn't crash the process, but it generates a high volume of error log entries (~400/day in our production environment across multiple services consuming the SDK).

We had to pin splitclient-rb < 8.11.0 in our wrapper gem to avoid this.

SDK Version

  • Affected: 8.11.0, master
  • Not affected: 8.10.1 and earlier

Root Cause

In lib/splitclient-rb/sse/event_source/client.rb, line 50 of the close method:

@config.logger.debug("SSEClient socket state #{@socket.state}") if @socket.is_a? OpenSSL::SSL::SSLSocket && @config.debug_enabled

Without explicit parentheses, Ruby parses the is_a? argument as:

@socket.is_a?(OpenSSL::SSL::SSLSocket && @config.debug_enabled)

Since OpenSSL::SSL::SSLSocket is truthy, && evaluates and returns the right operand (@config.debug_enabled, a boolean). Then is_a?(true) or is_a?(false) raises TypeError: class or module required.

Note that line 48 has a similar is_a? call but without &&, so it parses correctly:

@socket.sync_close = true if @socket.is_a? OpenSSL::SSL::SSLSocket  # works fine

Suggested Fix

Add explicit parentheses:

@config.logger.debug("SSEClient socket state #{@socket.state}") if @socket.is_a?(OpenSSL::SSL::SSLSocket) && @config.debug_enabled

Happy to submit a PR for this if that's helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions