mini_racer-csim 0.21.1.4 → 0.21.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a64c6a3cd59b38b736212c4ef9685cbc7c6bc9e56d0aee12734e957e749fb7c
4
- data.tar.gz: 50e7e8a671b90f3bf2e6563092f31ed00edf7d2c8093eb52eccbe502635773ca
3
+ metadata.gz: 18ed230356524c1098d8809a51fdee97a601f949e027f86ec7e393869ab8daf2
4
+ data.tar.gz: ab81fcad2a27c063af01ae4d6a8f66c9d2025fadd555f8e0036034f9e12adf38
5
5
  SHA512:
6
- metadata.gz: 53cb234c4dca6643756f5f0558080dade542569bf64aef713e0f44477e05d2c7e14bc305f63671519d67131a63f35dcee65829893dd493011b5f2764552677bd
7
- data.tar.gz: ee5e61767e56179bf2aec29c54ca81d0f3c6b3ad7d1788498bb45b84ee5f7d3b6dcb613cc5f297dbdcb4eae32f4005b594a6a7a562d51c9d1904b646537976cb
6
+ metadata.gz: 71fd179510efac57fdf0222cebb84bea43d678df1672a3281ed431ed11f7af1ada36de3ddfd832b2ccbdeb619ceb789f4a6f3d98671d8a7a830fababfef0c172
7
+ data.tar.gz: 20a5df4c74fbda09d2801d777ce4d205e696110216ed5d85107126228808a4da6074189a29c0a7da2ebb6f1d7a6af86877b7aa528eb063f2795f0b4d0e546229
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ - 0.21.1.5 - 08-06-2026
2
+ - Fix a process abort when a reply value is still not cloneable after the safe-context filter runs (e.g. it contains a `Symbol`, which the filter passes through). The filter slow path returned `false` without re-throwing, so its local `TryCatch` cleared the pending exception and the caller hit `assert(try_catch.HasCaught())`. The clone failure is now propagated and surfaced as the usual `{"error" => "… could not be cloned"}` response. (Latent before 0.21.1.4; the 0.21.1.4 filter memoization made the path reachable for cyclic values.)
3
+
1
4
  - 0.21.1.4 - 08-06-2026
2
5
  - Memoize the safe-context reply filter (the recursive deep-copy fallback used when a reply value is not cloneable by V8's ValueSerializer — e.g. it contains a function or a host object). A visited-set (original → filtered copy) makes shared subgraphs clone once instead of being re-walked per reference path (O(N) instead of super-linear), terminates cycles (previously a cyclic value containing a non-cloneable member recursed forever), and preserves object identity — matching the ValueSerializer fast path it backs
3
6
 
data/README.md CHANGED
@@ -483,7 +483,9 @@ Without `drain()` the order would be `["before", "after", "microtask"]` because
483
483
 
484
484
  When the drain has to happen from within JavaScript itself — for example between each listener in a synchronous `dispatchEvent` chain — the same checkpoint is available to JS as `drainMicrotasks()`. It runs inline on the V8 thread without the Ruby ↔ V8 round-trip, so no `attach` is required.
485
485
 
486
- It is exposed through an opt-in **host namespace** — a single object (in the spirit of Deno's `Deno` or Bun's `Bun`) that mini_racer hangs its non-standard helpers off. Pass `host_namespace:` to enable it; by default nothing is injected and the global stays clean:
486
+ ### Host namespace
487
+
488
+ `mini_racer-csim` exposes its non-standard JS-callable helpers through a single opt-in object (in the spirit of Deno's `Deno` or Bun's `Bun`) rather than as bare globals, so allowing them is a one-time decision and `globalThis` otherwise stays clean. Pass `host_namespace:` to enable it; by default nothing is injected:
487
489
 
488
490
  ```ruby
489
491
  context = MiniRacerCsim::Context.new(host_namespace: "MiniRacer")
@@ -498,6 +500,8 @@ context.eval("log")
498
500
  # => ["before", "microtask", "after"]
499
501
  ```
500
502
 
503
+ Beyond `drainMicrotasks()`, the namespace also carries the per-frame-realm JS helpers — `realmGlobal(id)`, `realmOf(fn)`, and `onUnhandledRejection(fn)` (see the **Per-frame realms** entry above). They live here for the same reason, so cross-realm wiring *in JS* requires `host_namespace:`; realms driven from Ruby (`Context#create_realm` + `Realm#eval`/`call`) do not.
504
+
501
505
  `host_namespace:` accepts a String (the global name to use — it must be a valid JavaScript identifier), `true` (the default name `"MiniRacer"`), or `nil`/`false` (the default — inject nothing). The namespace object is defined non-enumerable so it does not appear in `Object.keys(globalThis)`, while its methods are ordinary properties discoverable via `Object.keys(MiniRacer)`. Like `perform_microtask_checkpoint`, `drainMicrotasks()` is a no-op while a microtask checkpoint is already in progress, and it lets watchdog/out-of-memory termination propagate to the enclosing `eval`/`call`.
502
506
 
503
507
  ### ES modules
@@ -273,9 +273,26 @@ bool reply(State& st, v8::Local<v8::Value> v)
273
273
  return false;
274
274
  }
275
275
  Serialized serialized(st, v);
276
- if (serialized.data)
276
+ if (serialized.data) {
277
277
  v8_reply(st.ruby_context, serialized.data, serialized.size);
278
- return serialized.data != nullptr; // exception pending if false
278
+ return true;
279
+ }
280
+ // The filtered value still is not serializable — e.g. it contains a Symbol,
281
+ // which the filter passes through unchanged (it only drops functions).
282
+ // ValueSerializer may signal this by returning false WITHOUT throwing, in
283
+ // which case the bare `return false` below would propagate no exception:
284
+ // this TryCatch would clear it on destruction and the caller would hit
285
+ // `assert(try_catch.HasCaught())`. Maintain the invariant that reply()==false
286
+ // implies a pending, propagated exception — synthesize a clone error when
287
+ // none was thrown — so the caller returns the {"error": ...} response
288
+ // instead of aborting. The "could not be cloned" wording matches the
289
+ // heuristic in the 3-arg reply().
290
+ if (!try_catch.HasCaught()) {
291
+ st.isolate->ThrowException(v8::Exception::Error(
292
+ v8::String::NewFromUtf8Literal(st.isolate, "value could not be cloned")));
293
+ }
294
+ try_catch.ReThrow();
295
+ return false;
279
296
  }
280
297
 
281
298
  bool reply(State& st, v8::Local<v8::Value> result, v8::Local<v8::Value> err)
@@ -4,6 +4,6 @@ module MiniRacerCsim
4
4
  # mini_racer-csim fork: upstream version + a fork revision segment.
5
5
  # 0.21.1.0 = first fork release on upstream 0.21.1; bump the 4th segment for
6
6
  # fork-only changes, reset it when rebasing onto a new upstream version.
7
- VERSION = "0.21.1.4"
7
+ VERSION = "0.21.1.5"
8
8
  LIBV8_NODE_VERSION = "~> 24.12.0.1"
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_racer-csim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.1.4
4
+ version: 0.21.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keita Urashima