Title: Hypermodel `after_commit` handler is dropping errors instead of raising · Issue #453 · hyperstack-org/hyperstack · GitHub
Open Graph Title: Hypermodel `after_commit` handler is dropping errors instead of raising · Issue #453 · hyperstack-org/hyperstack
X Title: Hypermodel `after_commit` handler is dropping errors instead of raising · Issue #453 · hyperstack-org/hyperstack
Description: 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 polic...
Open Graph Description: 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 pu...
X Description: 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 pu...
Opengraph URL: https://github.com/hyperstack-org/hyperstack/issues/453
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Hypermodel `after_commit` handler is dropping errors instead of raising","articleBody":"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.\r\n\r\n```ruby\r\ndef self.after_commit(operation, model)\r\n # Calling public_columns_hash once insures all policies are loaded\r\n # before the first broadcast.\r\n @public_columns_hash ||= ActiveRecord::Base.public_columns_hash\r\n Hyperstack::InternalPolicy.regulate_broadcast(model) do |data|\r\n puts \"Broadcast aftercommit hook: #{data}\" if Hyperstack::Connection.show_diagnostics\r\n\r\n if !Hyperstack.on_server? \u0026\u0026 Hyperstack::Connection.root_path\r\n send_to_server(operation, data, model.__synchromesh_update_time) rescue nil # fails if server no longer running so ignore\r\n else\r\n SendPacket.run(data, operation: operation, updated_at: model.__synchromesh_update_time)\r\n end\r\n end\r\nrescue ActiveRecord::StatementInvalid =\u003e e\r\n raise e unless e.message == \"Could not find table 'hyperstack_connections'\"\r\nend unless RUBY_ENGINE == 'opal'\r\n```\r\n\r\nThe line containing `SendPacket` should be \r\n```ruby\r\nSendPacket.run(data, operation: operation, updated_at: model.__synchromesh_update_time).tap { |p| raise p.error if p.error }\r\n```\r\n\r\nThe easiest way to patch this is by adding this:\r\n\r\n```ruby\r\nmodule Hyperstack\r\n class InternalPolicy\r\n alias original_send_message send_message\r\n def send_message(*args, \u0026block)\r\n original_send_message(*args, \u0026block).tap { |p| raise p.error if p.is_a?(Promise) \u0026\u0026 p.error }\r\n end \r\n end\r\nend\r\n```\r\n\r\nThis will catch the error with the smallest patch. Note the patch needs to check if its a promise, but the actual fix does not.","author":{"url":"https://github.com/catmando","@type":"Person","name":"catmando"},"datePublished":"2023-03-27T20:02:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/453/hyperstack/issues/453"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:15a0f93c-f4f7-5692-13d8-6b50ab3c6d4b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A128:14F0F1:1C45C26:245FD4B:699278CE |
| html-safe-nonce | e7567d282573971a07ffe6d83e3f52ffe80972e62eb6abf4aab9a9a3a8925393 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTI4OjE0RjBGMToxQzQ1QzI2OjI0NUZENEI6Njk5Mjc4Q0UiLCJ2aXNpdG9yX2lkIjoiMTgyMjc4Mjg4MDk0ODA1ODMxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c32215ae86af0c12054c5dcf8847b2f0e915175d4dc8838bc3e4c9d970e47d65 |
| hovercard-subject-tag | issue:1642731229 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hyperstack-org/hyperstack/453/issue_layout |
| twitter:image | https://opengraph.githubassets.com/460272878067fbc3fc40853364de5107b17daf38e985bd05fbf1a6b4a6eb887c/hyperstack-org/hyperstack/issues/453 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/460272878067fbc3fc40853364de5107b17daf38e985bd05fbf1a6b4a6eb887c/hyperstack-org/hyperstack/issues/453 |
| og:image:alt | 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 pu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | catmando |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/hyperstack-org/hyperstack git https://github.com/hyperstack-org/hyperstack.git |
| octolytics-dimension-user_id | 34562730 |
| octolytics-dimension-user_login | hyperstack-org |
| octolytics-dimension-repository_id | 145879576 |
| octolytics-dimension-repository_nwo | hyperstack-org/hyperstack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145879576 |
| octolytics-dimension-repository_network_root_nwo | hyperstack-org/hyperstack |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width