Allow to use this gem in a Ractor - #73
Open
Edouard-chin wants to merge 1 commit into
Open
Conversation
- Fix gshutler#70 - ### Problem I'd like to be able to use this gem inside a Ractor. This is currently not possible because all strings in this library aren't frozen. ```ruby Ractor.new do UserAgent::Browsers::Chrome::ChromeBrowsers end.join # <Thread:0x0000000127f1d128 run> terminated with exception (report_on_exception is true): # 'block in <top (required)>': can not access non-shareable objects in constant UserAgent::Browsers::Chrome::ChromeBrowsers by non-main Ractor. (Ractor::IsolationError) ``` ### Solution There is no codepaths that depend on mutating these strings so the solution is as simple as turning on the `frozen_string_literal` magic comment.
Author
|
@gshutler Sorry to bother and thanks a lot for your work on this gem. Do you by any chance still maintain this gem, and if yes would you mind having a look at this PR which should be straightforward I think. For context, I discovered this problem in this gem because we are trying to change Rails to be able to serve requests from a Ractor (and Rails uses this gem as traversal dependencies for allowing/denying certain browsers). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #70
Problem
I'd like to be able to use this gem inside a Ractor. This is currently not possible because all strings in this library aren't frozen.
Solution
There is no codepaths that depend on mutating these strings so the solution is as simple as turning on the
frozen_string_literalmagic comment.