Hypermodel `after_commit` handler is dropping errors instead of raising
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
調査の方向性
Hypermodel の after_commit メソッドから始めて SendPacket.run の結果を調べ、その後 InternalPolicy#send_message を読んで promise のエラーがどのように処理されるかを理解します。after-commit broadcast からのエラーが破棄されずに raise され、server-not-running rescue は変更されない状態になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
in the after_commit method of hypermodel, the SendPacket operation is run which will return a promise, but it is not checked for an error state.
def self.after_commit(operation, model)
# Calling public_columns_hash once insures all policies are loaded
# before the first broadcast.
@public_columns_hash ||= ActiveRecord::Base.public_columns_hash
Hyperstack::InternalPolicy.regulate_broadcast(model) do |data|
puts "Broadcast aftercommit hook: #{data}" if Hyperstack::Connection.show_diagnostics
if !Hyperstack.on_server? && Hyperstack::Connection.root_path
send_to_server(operation, data, model.__synchromesh_update_time) rescue nil # fails if server no longer running so ignore
else
SendPacket.run(data, operation: operation, updated_at: model.__synchromesh_update_time)
end
end
rescue ActiveRecord::StatementInvalid => e
raise e unless e.message == "Could not find table 'hyperstack_connections'"
end unless RUBY_ENGINE == 'opal'
The line containing SendPacket should be
SendPacket.run(data, operation: operation, updated_at: model.__synchromesh_update_time).tap { |p| raise p.error if p.error }
The easiest way to patch this is by adding this:
module Hyperstack
class InternalPolicy
alias original_send_message send_message
def send_message(*args, &block)
original_send_message(*args, &block).tap { |p| raise p.error if p.is_a?(Promise) && p.error }
end
end
end
This will catch the error with the smallest patch. Note the patch needs to check if its a promise, but the actual fix does not.
- 主要言語
- JavaScript
- スター
- 538
- フォーク
- 41
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hyperstack-org/hyperstack のほかの issue
-
enhancement needs doc
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
hyperstack-org/hyperstack#359 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
hyperstack-org/hyperstack#267 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
hyperstack-org/hyperstack#457 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
hyperstack-org/hyperstack#456 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
hyperstack-org/hyperstack#455 · コメント 2 件 ·
hyperstack-org/hyperstack の issue をすべて見る
似ている issue
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-webui/open-webui#30750 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100