Skip to content

Conversation

@davidtaylorhq
Copy link
Collaborator

This enables persisting snapshots to disk for faster startup. Complements the existing Snapshot#dump method.

snapshot = MiniRacer::Snapshot.new('var foo = "bar";')
File.binwrite("snapshot.bin", snapshot.dump)

blob = File.binread("snapshot.bin")
restored = MiniRacer::Snapshot.load(blob)
ctx = MiniRacer::Context.new(snapshot: restored)

This enables persisting snapshots to disk for faster startup. Complements the existing `Snapshot#dump` method.

```
snapshot = MiniRacer::Snapshot.new('var foo = "bar";')
File.binwrite("snapshot.bin", snapshot.dump)

blob = File.binread("snapshot.bin")
restored = MiniRacer::Snapshot.load(blob)
ctx = MiniRacer::Context.new(snapshot: restored)
```
Set ENC_CODERANGE_VALID on loaded snapshot blobs to prevent
Ruby from treating binary data as broken encoding when the
input string has non-binary encoding (e.g., UTF-8).

Also adds security warning to README about loading untrusted
snapshots, and expands test coverage for encoding handling.
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

Successfully merging this pull request may close these issues.

3 participants