Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Hypermodel `after_commit` handler is dropping errors instead of raising

Aperta
#453 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
rails, ruby
Ambito
backend

Direzione di ricerca

Inizia dal metodo after_commit di Hypermodel e analizza il risultato di SendPacket.run, quindi leggi InternalPolicy#send_message per capire come vengono gestiti gli errori delle promise. Il lavoro è completato quando gli errori dell’after-commit broadcast vengono sollevati invece di essere ignorati, mentre il server-not-running rescue rimane invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
538
Fork
41
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hyperstack-org/hyperstack

Tutte le issue di hyperstack-org/hyperstack

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.