RestClient::Request.execute crashes inside a thread in ruby 2.5.7 (on windows) works in ruby 2.3.1
afanofosc opened this issue · comments
https://stackoverflow.com/questions/54029115/ruby-thread-terminates-abruptly-when-using-rest-client
I am having exactly the same problem as described at the above link. Running on Windows - not sure that the version of windows matters. A call to RestClient::Request.execute outside of a thread works correctly. Inside a thread it crashes. It works with Ruby 2.3.1 (ruby 2.3.1p112 (2016-04-26 revision 54768) [i386-mingw32]) but does not work with Ruby 2.5.7 (ruby 2.5.7p206 (2019-10-01 revision 67816) [x64-mingw32]).
Take any valid call to RestClient::Request.execute and wrap it in Thread.new { }.join and it will crash with Ruby 2.5.7. Like this:
require 'rest-client'
# uncomment the following line (and below) for crash with ruby 2.5.7p206 (2019-10-01 revision > 67816) [x64-mingw32]
#test_thread = Thread.new {
puts "about to call RestClient::Request.execute"
response = RestClient::Request.execute({
method: :post,
url: 'https://rest.endpoint.com/foo/bar',
user: 'username',
password: 'password',
payload: {grant_type: 'some_grant_type', scope: 'TheScope'},
headers: {:accept => :json, content_type: :'application/x-www-form-urlencoded'}
})
puts "finished calling RestClient::request.execute"
puts response
# uncomment this line for crash with Ruby 2.5.7. Works fine with Ruby 2.3.1.
#}.join
puts "this worked"
We are using 2.0.2 so perhaps this problem has been fixed in a more recent version?
I just tested with 2.1.0 and that fixed the problem. My apologies for prematurely creating an issue.