feat: add global MiniRacer pause gate - #430
Conversation
|
Thanks for building this — the pause gate is a nice primitive, and Setup: Rails app rendering pages through execjs/mini_racer, puma The fault is in V8's platform rather than in a mini_racer operation:
Two suggestions, both smaller than a V8 change: 1. Extend the fork guard to default-mode contexts. You already handle this for the single-threaded typedef struct Context {
...
+ pid_t pid; // process that created this context; guards post-fork use
pthread_t single_threaded_thr; if (!a->started) {
if (single_threaded && (r = single_threaded_recover_after_fork(c))) {
rendezvous_release(a);
return (void *)(intptr_t)r;
}
+ if (!single_threaded && c->pid != getpid()) {
+ rendezvous_release(a);
+ return (void *)(intptr_t)ESRCH; // inherited context; v8 thread is gone
+ }2. Say something at Happy to share the full backtrace, or to test a patch against the same load. We're dropping |
|
Thanks for testing @natevick ... how is latest feeling? |
Add MiniRacer.pause/resume to quiesce operations process-wide with timeout handling and nested pauses. Expose PauseTimeoutError and opt-in Process._fork hooks so fork can wait for MiniRacer to drain before parent and child continue. Document the fork coordination APIs and cover pause, timeout, hook, and single-threaded fork behavior with tests.
Track V8 platform ownership and context state across forks, and raise MiniRacer::ForkError when a child attempts to use unrecoverable inherited state. Keep quiescent single-threaded contexts usable while rejecting busy ones. Warn when fork hooks are used with the default platform, and document why pause hooks cannot restore its missing worker threads. Add coverage for platform initialization races, inherited context cleanup, and safe child initialization.
Add MiniRacer.pause/resume to quiesce operations process-wide with timeout handling and nested pauses. Expose PauseTimeoutError and opt-in Process._fork hooks so fork can wait for MiniRacer to drain before parent and child continue.
Document the fork coordination APIs and cover pause, timeout, hook, and single-threaded fork behavior with tests.