提交 ff56fdb0 编写于 作者: F Francesco Rodriguez

Preload digest/sha2 to avoid thread safe error.

I got this error in production using Puma in multi-threaded mode:

```
RuntimeError: Digest::Base cannot be directly inherited in Ruby
from active_support/security_utils.rb:23:in `variable_size_secure_compare'
from active_support/security_utils.rb:23:in `hexdigest'
from active_support/security_utils.rb:23:in `digest'
```

Looks like Digest uses const_missing to load Digest::SHA256 (https://github.com/ruby/ruby/blob/trunk/ext/digest/lib/digest.rb#L8)

- https://bugs.ruby-lang.org/issues/9494
- https://github.com/ruby/ruby/commit/c02fa39463a0c6bf698b01bc610135604aca2ff4
上级 ab08f33f
......@@ -2,7 +2,7 @@
require_relative "../../migration/join_table"
require "active_support/core_ext/string/access"
require "digest"
require "digest/sha2"
module ActiveRecord
module ConnectionAdapters # :nodoc:
......
# frozen_string_literal: true
require "digest"
require "digest/sha2"
module ActiveSupport
module SecurityUtils
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册