Skip to content

Commit

Permalink
Check msgpack freeze support in JSON compile cache
Browse files Browse the repository at this point in the history
Ref: #395
  • Loading branch information
byroot committed Jan 17, 2022
1 parent e677919 commit 1da7c3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Unreleased

* Better check `freeze` option support in JSON compile cache.
Previously `JSON.load_file(..., freeze: true)` would be cached even when the msgpack version is missing support for it.

# 1.10.1

* Fix `Kernel#autoload`'s fallback path always being executed.
Expand Down
4 changes: 3 additions & 1 deletion lib/bootsnap/compile_cache/json.rb
Expand Up @@ -52,7 +52,9 @@ def init!
self.msgpack_factory = MessagePack::Factory.new
self.supported_options = [:symbolize_names]
if ::JSON.parse('["foo"]', freeze: true).first.frozen?
self.supported_options = [:freeze]
if MessagePack.load(MessagePack.dump("foo"), freeze: true).frozen?
self.supported_options = [:freeze]
end
end
supported_options.freeze
end
Expand Down

0 comments on commit 1da7c3c

Please sign in to comment.