Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Uncaught exception: can't dump IO #5022

Merged
merged 1 commit into from
Oct 13, 2021

Conversation

ivy
Copy link
Contributor

@ivy ivy commented Oct 13, 2021

An error occurs when the underlying Redis client is configured with a logger, due to the limitations of Marshal when dealing with IO objects. This change excludes the :logger option in a similar fashion to the way :ssl_params is currently excluded.

This error can be reproduced with the following:

Sidekiq.configure_client do |config|
  config.redis = { logger: Logger.new(STDOUT) }
end

The complete exception message and stacktrace is as follows:

Uncaught exception: can't dump IO
	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq/redis_connection.rb:103:in `dump'
	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq/redis_connection.rb:103:in `log_info'
	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq/redis_connection.rb:32:in `create'
	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq.rb:137:in `redis='

Note: I recognize this isn't a common need but it's useful for enabling some additional debug logging from the Redis driver.

An error occurs when the underlying Redis client is configured with a
logger, due to the limitations of `Marshal` when dealing with `IO`
objects. This change excludes the `:logger` option in a similar fashion
to the way `:ssl_params` is currently excluded.

This error can be reproduced with the following:

    Sidekiq.configure_client do |config|
      config.redis = { logger: Logger.new(STDOUT) }
    end

The complete exception message and stacktrace is as follows:

    Uncaught exception: can't dump IO
    	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq/redis_connection.rb:103:in `dump'
    	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq/redis_connection.rb:103:in `log_info'
    	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq/redis_connection.rb:32:in `create'
    	/usr/local/bundle/gems/sidekiq-6.2.2/lib/sidekiq.rb:137:in `redis='
@mperham mperham merged commit 1f05bd6 into sidekiq:main Oct 13, 2021
@ivy ivy deleted the fix-error-when-passing-logger branch October 13, 2021 00:16
@ivy
Copy link
Contributor Author

ivy commented Oct 13, 2021

Thanks for the fast merge! ❤️

@mperham
Copy link
Collaborator

mperham commented Oct 13, 2021

Don't thank me until CI passes! 😂

Thank you for the fix.

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.

None yet

2 participants