Skip to content

Hypermodel after_commit handler is dropping errors instead of raising #453

Description

@catmando

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.

defself.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_hashHyperstack::InternalPolicy.regulate_broadcast(model)do |data|
puts"Broadcast aftercommit hook: #{data}"ifHyperstack::Connection.show_diagnosticsif !Hyperstack.on_server? && Hyperstack::Connection.root_pathsend_to_server(operation,data,model.__synchromesh_update_time)rescuenil# fails if server no longer running so ignoreelseSendPacket.run(data,operation: operation,updated_at: model.__synchromesh_update_time)endendrescueActiveRecord::StatementInvalid=>eraiseeunlesse.message == "Could not find table 'hyperstack_connections'"endunlessRUBY_ENGINE == 'opal'

The line containing SendPacket should be

SendPacket.run(data,operation: operation,updated_at: model.__synchromesh_update_time).tap{ |p| raisep.errorifp.error}

The easiest way to patch this is by adding this:

moduleHyperstackclassInternalPolicyaliasoriginal_send_messagesend_messagedefsend_message(*args, &block)original_send_message(*args, &block).tap{ |p| raisep.errorifp.is_a?(Promise) && p.error}endendend

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions