Skip to content

Commit

Permalink
Fix "can't alloc thread" exception on exit (rubyjs#310)
Browse files Browse the repository at this point in the history
It's no longer possible to create new threads once Ruby's main thread
has exited.
  • Loading branch information
bnoordhuis authored Aug 16, 2024
1 parent 87ef545 commit 6366ea1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/mini_racer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def ensure_gc_thread
@last_eval = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@ensure_gc_mutex.synchronize do
@ensure_gc_thread = nil if !@ensure_gc_thread&.alive?
return if !Thread.main.alive? # avoid "can't alloc thread" exception
@ensure_gc_thread ||= Thread.new do
ensure_gc_after_idle_seconds = @ensure_gc_after_idle / 1000.0
done = false
Expand Down

0 comments on commit 6366ea1

Please sign in to comment.