Skip to content
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

FrozenError on Ruby 3.0.0 #640

Closed
TeroPihlaja opened this issue Dec 31, 2020 · 1 comment
Closed

FrozenError on Ruby 3.0.0 #640

TeroPihlaja opened this issue Dec 31, 2020 · 1 comment

Comments

@TeroPihlaja
Copy link

http gem 3.3.0 running on Ruby 3.0.0 seems to be causing FrozenError: can't modify frozen String: "" exception in the following case:

.../gems/http-3.3.0/lib/http/response/body.rb:52:in `force_encoding'
.../gems/http-3.3.0/lib/http/response/body.rb:52:in `to_s'
.../gems/http-3.3.0/lib/http/response.rb:92:in `flush'

I was checking the reason for this error and it sseems to be caused by the following lines:
https://github.com/httprb/http/blob/3-x-stable/lib/http/response/body.rb#L52

@contents   = String.new("").force_encoding(@encoding)
...
@contents << chunk.force_encoding(@encoding)

Also same pattern repeats in master so I believe that is also affected (but did not test):

@contents << chunk.force_encoding(@encoding)

@TeroPihlaja
Copy link
Author

Seems to already be fixed in 4.4.1. Closing issue.

troysurrett pushed a commit to troysurrett/brightcove-cmsapi that referenced this issue Jan 17, 2022
When consuming this gem in my application, I would sometimes get errors like this:
FrozenError: can't modify frozen String: ""
File /app/vendor/bundle/ruby/2.7.0/gems/http-2.2.2/lib/http/response/body.rb line 57 in force_encoding
File /app/vendor/bundle/ruby/2.7.0/gems/http-2.2.2/lib/http/response/body.rb line 57 in to_s
File /app/vendor/ruby-2.7.4/lib/ruby/2.7.0/forwardable.rb line 235 in to_s

This seems to happen when the response body is empty. Researching the issue leads me to this Github Issue page for the
http gem: httprb/http#640

Which indicates that this is indeed a bug with the 2.2.2 release of the http gem, and there is no fix for it other than
to upgrade to the 4.4.1 release. I have been able to use the brightcove-cmsapi gem with the 4.4.1 version of the http
gem so far without issue.
bunnymatic pushed a commit to rcode5/dropbox-sdk-ruby that referenced this issue Mar 10, 2024
problem
------

http lib had a problem.

httprb/http#640

solution
------

upgrade http and webmock
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

No branches or pull requests

1 participant