Readme: Add note about V8 single threaded platform mode (#239)

* changes link to supported Rubies to "Ruby Maintenance Branches"

This pages lists the support status of different Ruby versions
alongside with a note on the respective EOLs.

* adds note to "Fork safety" about V8 single threaded platform mode
This commit is contained in:
Sebastian Cohnen 2022-02-14 07:50:02 +01:00 committed by GitHub
parent 38820e54fd
commit 15051f2298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions

View File

@ -12,7 +12,7 @@ MiniRacer has an adapter for [execjs](https://github.com/rails/execjs) so it can
### A note about Ruby version Support
MiniRacer only supports non-EOL versions of Ruby. See [Ruby](https://www.ruby-lang.org/en/downloads) to see the list of non-EOL Rubies.
MiniRacer only supports non-EOL versions of Ruby. See [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/) for the list of non-EOL Rubies.
If you require support for older versions of Ruby install an older version of the gem.
@ -112,16 +112,21 @@ context.eval('bar()', filename: 'a/bar.js')
### Fork safety
Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe.
Sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe by default and sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
Since 0.6.1 mini_racer does support V8 single threaded platform mode which should remove most forking related issues. To enable run this before using `MiniRacer::Context`:
```ruby
MiniRacer::Platform.set_flags!(:single_threaded)
```
If you want to ensure your application does not leak memory after fork either:
1. Ensure no MiniRacer::Context objects are created in the master process
1. Ensure no `MiniRacer::Context` objects are created in the master process
Or
2. Dispose manually of all MiniRacer::Context objects prior to forking
2. Dispose manually of all `MiniRacer::Context` objects prior to forking
```ruby
# before fork