Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Show the class variable name which caused a RactorIsolationError #13236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

osyoyu
Copy link
Contributor

@osyoyu osyoyu commented May 2, 2025

Class variable (@@var) access is prohibited in non-main Ractors and causes a RactorIsolationError.
Currently, RactorIsolationErrors do not carry any information about the actual class variable access which caused the violation. This makes it hard to debug non-Ractor-compatible code, especially when the culprit is in the middle of a long line.

This patch adds the class variable name which triggered the RactorIsolationError into its message. This follows the pattern of the "can not access non-shareable objects in constant FOO" error.

Class variable (@@var) access is prohibited in non-main Ractors and
causes a RactorIsolationError.
Currently, RactorIsolationErrors do not carry any information about the
actual class variable access which caused the violation. This makes it
hard to debug non-Ractor-compatible code, especially when the culprit is
in the middle of a long line.

This patch adds the class variable name which triggered the
RactorIsolationError into its message. This follows the pattern of the
"can not access non-shareable objects in constant FOO" error.
@osyoyu
Copy link
Contributor Author

osyoyu commented May 2, 2025

Example:

Before

Ractor::IsolationError: can not access class variables from non-main Ractors
        from .../sinatra/lib/sinatra/show_exceptions.rb:26:in 'Sinatra::ShowExceptions#call'
        from .../sinatra/lib/sinatra/base.rb:227:in 'Sinatra::ExtendedRack#call'
        from .../sinatra/lib/sinatra/base.rb:2144:in 'Sinatra::Wrapper#call'

After

Ractor::IsolationError: can not access class variable @@eats_errors from non-main Ractors
        from .../sinatra/lib/sinatra/show_exceptions.rb:26:in 'Sinatra::ShowExceptions#call'
        from .../sinatra/lib/sinatra/base.rb:227:in 'Sinatra::ExtendedRack#call'
        from .../sinatra/lib/sinatra/base.rb:2144:in 'Sinatra::Wrapper#call'

Error originating here.
https://github.com/sinatra/sinatra/blob/91cfb548c9e50a65324a9ce9e4ea5f10cd897027/lib/sinatra/show_exceptions.rb#L26

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.

1 participant