Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Unexpected exception on redis disconnect Redis - NoMethodError(undefined method `destroy' for nil:NilClass)

未关闭
#362 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
rails, redis, ruby
领域
backend

调研方向

从 ruby/hyper-operation/transport/connection_adapter/redis.rb 第 66 行开始,然后阅读经过 connection.rb 和 action_cable.rb 的 disconnect 调用链。跟踪 Redis 断开连接路径为何会在 nil 上调用 destroy;完成标准是断开 channel 不再引发报告中的 NoMethodError。

由索引模型根据 Issue 内容生成。

描述

I switched recently to the new Redis message functionality and I get the following exception in production.log

I, [2021-02-25T14:13:45.826641 #1289]  INFO -- : Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-02-25 14:13:45 +0200
I, [2021-02-25T14:13:45.830986 #1289]  INFO -- : Hyperstack::ActionCableChannel stopped streaming from hyperstack-AnnouncementCategory
I, [2021-02-25T14:13:45.926758 #1266]  INFO -- : Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-02-25 14:13:45 +0200
I, [2021-02-25T14:13:45.933053 #1266]  INFO -- : Hyperstack::ActionCableChannel stopped streaming from hyperstack-AnnouncementCategory
I, [2021-02-25T14:13:46.010028 #1266]  INFO -- : Hyperstack::ActionCableChannel stopped streaming from hyperstack-Epos::Applicant-423783
I, [2021-02-25T14:13:46.028519 #1266]  INFO -- : Hyperstack::ActionCableChannel stopped streaming from hyperstack-Hyperstack::Session-e570d5777171d6ae432a94fef3735d11
E, [2021-02-25T14:13:46.159163 #1289] ERROR -- : There was an exception - NoMethodError(undefined method `destroy' for nil:NilClass)
E, [2021-02-25T14:13:46.162694 #1289] ERROR -- : /home/app/shared/bundle/ruby/2.7.0/bundler/gems/hyperstack-f07d016b626a/ruby/hyper-operation/lib/hyper-operation/transport/connection_adapter/redis.rb:66:in `disconnect'
/home/app/shared/bundle/ruby/2.7.0/bundler/gems/hyperstack-f07d016b626a/ruby/hyper-operation/lib/hyper-operation/transport/connection.rb:68:in `disconnect'
/home/app/shared/bundle/ruby/2.7.0/bundler/gems/hyperstack-f07d016b626a/ruby/hyper-operation/lib/hyper-operation/transport/action_cable.rb:36:in `unsubscribed'

I had the same problem when using the db message store and back then i had to patch hyperstack.rb initializer with the following patch from @catmando :

module Hyperstack
  class Connection < ActiveRecord::Base
    def self.disconnect(channel)
      puts "\ndisconnecting from #{channel}\n" if Rails.env.development?
      c = find_by(channel: channel, session: nil)
      if c
        c.destroy
      else
        puts "\n********************** WARNING #{channel} has not been opened.  Why are we disconnecting ?????????? \n"
      end
    end
  end
end

Why is this happeing?

主要语言
JavaScript
星标
538
派生
41
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

hyperstack-org/hyperstack 的其他 Issue

查看 hyperstack-org/hyperstack 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。