Skip to content

Handle new execute_intent non-raising behaviour - #1048

Open
andrewn617 wants to merge 2 commits into
mainfrom
execute-intent-without-raising
Open

Handle new execute_intent non-raising behaviour#1048
andrewn617 wants to merge 2 commits into
mainfrom
execute-intent-without-raising

Conversation

@andrewn617

Copy link
Copy Markdown
Member

rails/rails#58049 refactored execute_intent to no longer raise errors. Instead execution errors are stored on the query intent and can be checked later by the caller. This is to pave the way for better async execution.

However, semian relies on the raising behaviour to trip the circuit breaker. With this change to Rails, any query that fails mid execution will be considered successful by Semian. And indeed ActiveRecordTrilogyAdapterTest#test_read_timeout_error_opens_the_circuit fails when we bump Rails to this commit.

To solve it, in our execute_intent patch we can check the intent for an error and raise it within the acquire_semian_resource block to trip the circuit breaker. Then we can rescue it and return the result to match the new Rails behaviour.

Comment thread lib/semian/activerecord_adapter.rb Outdated
Comment thread lib/semian/activerecord_adapter.rb
@andrewn617
andrewn617 force-pushed the execute-intent-without-raising branch from f7f369b to a426727 Compare September 3, 2026 19:29
…red on the query intent and raise it to trip the circuit breaker, then rescue and allow Rails to continue execution.
@andrewn617
andrewn617 force-pushed the execute-intent-without-raising branch from a426727 to 60406e6 Compare September 3, 2026 19:36
# any errors here to trip the circuit breaker. Then we can swallow the error and return the result for
# Rails to continue with.
if intent.respond_to?(:error)
delivered_error.equal?(intent.error)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be on line 77 where Adrianna commented

# Rails to continue with.
if intent.respond_to?(:error)
delivered_error.equal?(intent.error)
raise delivered_error if delivered_error

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully get were delivered_error gets assigned ?

@Edouard-chin Edouard-chin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to also rm -rf the Gemfile.lock before the bundle install steps kicks in on CI. This way we are sure bundler picks the latest Rails edge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants