hypha-rpc 0.21.38 → 0.21.41

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.
@@ -86,7 +86,7 @@
86
86
  <div class='footer quiet pad2 space-top1 center small'>
87
87
  Code coverage generated by
88
88
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
89
- at 2026-03-19T04:33:41.281Z
89
+ at 2026-06-13T15:47:34.767Z
90
90
  </div>
91
91
  <script src="prettify.js"></script>
92
92
  <script>
@@ -3365,6 +3365,14 @@ async function _connectToServerHTTP(config) {
3365
3365
  if (_getService.__schema__) {
3366
3366
  wm.getService.__schema__ = _getService.__schema__;
3367
3367
  }
3368
+ // Share the underlying RemoteFunction's encoded object so the
3369
+ // manager_refreshed retarget loop (which iterates wm[key].__rpc_object__)
3370
+ // can update getService's _rtarget after reconnection. Without this the
3371
+ // wrapper hides the original method and getService keeps a stale
3372
+ // "*/<old_manager_id>" target, causing a 400 on the next call.
3373
+ if (_getService.__rpc_object__) {
3374
+ wm.getService.__rpc_object__ = _getService.__rpc_object__;
3375
+ }
3368
3376
 
3369
3377
  async function serve() {
3370
3378
  await new Promise(() => {}); // Wait forever
@@ -4333,10 +4341,21 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4333
4341
 
4334
4342
  _create_message(key, heartbeat, overwrite, context) {
4335
4343
  if (heartbeat) {
4336
- if (!this._object_store[key]) {
4344
+ const session = this._object_store[key];
4345
+ if (!session) {
4337
4346
  throw new Error(`session does not exist anymore: ${key}`);
4338
4347
  }
4339
- this._object_store[key]["timer"].reset();
4348
+ // Sessions created without a promise/timeout (e.g. _get_session_store
4349
+ // calls where timer && reject && _method_timeout was false) have no
4350
+ // timer. A chunked message still arrives with heartbeat=true because
4351
+ // the sender sets it based on whether session_id is truthy (rpc.js
4352
+ // ~L2358), not on whether the receiver's session owns a timer. Without
4353
+ // this guard, every chunk of such a session throws "Cannot read
4354
+ // properties of undefined (reading 'reset')", which cascades and
4355
+ // silently breaks the RPC message pipeline for the client.
4356
+ if (session.timer && typeof session.timer.reset === "function") {
4357
+ session.timer.reset();
4358
+ }
4340
4359
  }
4341
4360
 
4342
4361
  if (!this._object_store["message_cache"]) {
@@ -4385,10 +4404,21 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4385
4404
 
4386
4405
  _append_message(key, data, heartbeat, context) {
4387
4406
  if (heartbeat) {
4388
- if (!this._object_store[key]) {
4407
+ const session = this._object_store[key];
4408
+ if (!session) {
4389
4409
  throw new Error(`session does not exist anymore: ${key}`);
4390
4410
  }
4391
- this._object_store[key]["timer"].reset();
4411
+ // Sessions created without a promise/timeout (e.g. _get_session_store
4412
+ // calls where timer && reject && _method_timeout was false) have no
4413
+ // timer. A chunked message still arrives with heartbeat=true because
4414
+ // the sender sets it based on whether session_id is truthy (rpc.js
4415
+ // ~L2358), not on whether the receiver's session owns a timer. Without
4416
+ // this guard, every chunk of such a session throws "Cannot read
4417
+ // properties of undefined (reading 'reset')", which cascades and
4418
+ // silently breaks the RPC message pipeline for the client.
4419
+ if (session.timer && typeof session.timer.reset === "function") {
4420
+ session.timer.reset();
4421
+ }
4392
4422
  }
4393
4423
  const cache = this._object_store["message_cache"];
4394
4424
  if (!cache[key]) {
@@ -4400,10 +4430,21 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4400
4430
 
4401
4431
  _set_message(key, index, data, heartbeat, context) {
4402
4432
  if (heartbeat) {
4403
- if (!this._object_store[key]) {
4433
+ const session = this._object_store[key];
4434
+ if (!session) {
4404
4435
  throw new Error(`session does not exist anymore: ${key}`);
4405
4436
  }
4406
- this._object_store[key]["timer"].reset();
4437
+ // Sessions created without a promise/timeout (e.g. _get_session_store
4438
+ // calls where timer && reject && _method_timeout was false) have no
4439
+ // timer. A chunked message still arrives with heartbeat=true because
4440
+ // the sender sets it based on whether session_id is truthy (rpc.js
4441
+ // ~L2358), not on whether the receiver's session owns a timer. Without
4442
+ // this guard, every chunk of such a session throws "Cannot read
4443
+ // properties of undefined (reading 'reset')", which cascades and
4444
+ // silently breaks the RPC message pipeline for the client.
4445
+ if (session.timer && typeof session.timer.reset === "function") {
4446
+ session.timer.reset();
4447
+ }
4407
4448
  }
4408
4449
  const cache = this._object_store["message_cache"];
4409
4450
  if (!cache[key]) {
@@ -4423,10 +4464,21 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4423
4464
 
4424
4465
  _process_message(key, heartbeat, context) {
4425
4466
  if (heartbeat) {
4426
- if (!this._object_store[key]) {
4467
+ const session = this._object_store[key];
4468
+ if (!session) {
4427
4469
  throw new Error(`session does not exist anymore: ${key}`);
4428
4470
  }
4429
- this._object_store[key]["timer"].reset();
4471
+ // Sessions created without a promise/timeout (e.g. _get_session_store
4472
+ // calls where timer && reject && _method_timeout was false) have no
4473
+ // timer. A chunked message still arrives with heartbeat=true because
4474
+ // the sender sets it based on whether session_id is truthy (rpc.js
4475
+ // ~L2358), not on whether the receiver's session owns a timer. Without
4476
+ // this guard, every chunk of such a session throws "Cannot read
4477
+ // properties of undefined (reading 'reset')", which cascades and
4478
+ // silently breaks the RPC message pipeline for the client.
4479
+ if (session.timer && typeof session.timer.reset === "function") {
4480
+ session.timer.reset();
4481
+ }
4430
4482
  }
4431
4483
  const cache = this._object_store["message_cache"];
4432
4484
  (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(!!context, "Context is required");
@@ -11476,6 +11528,13 @@ async function connectToServer(config) {
11476
11528
  description,
11477
11529
  parameters,
11478
11530
  });
11531
+ // webrtcGetService routes through _wm.getService (the original
11532
+ // RemoteFunction captured in the shallow copy). Share its encoded object
11533
+ // so the manager_refreshed retarget loop updates the manager target it
11534
+ // uses after reconnection, instead of leaving a stale "*/<old_manager_id>".
11535
+ if (_wm.getService && _wm.getService.__rpc_object__) {
11536
+ wm.getService.__rpc_object__ = _wm.getService.__rpc_object__;
11537
+ }
11479
11538
 
11480
11539
  wm.getRTCService = (0,_utils_schema_js__WEBPACK_IMPORTED_MODULE_3__.schemaFunction)(_webrtc_client_js__WEBPACK_IMPORTED_MODULE_4__.getRTCService.bind(null, wm), {
11481
11540
  name: "getRTCService",
@@ -11504,6 +11563,12 @@ async function connectToServer(config) {
11504
11563
  return svc;
11505
11564
  };
11506
11565
  wm.getService.__schema__ = _getService.__schema__;
11566
+ // Share the underlying RemoteFunction's encoded object so the
11567
+ // manager_refreshed retarget loop can update getService's _rtarget after
11568
+ // reconnection (otherwise the wrapper retains a stale manager target).
11569
+ if (_getService.__rpc_object__) {
11570
+ wm.getService.__rpc_object__ = _getService.__rpc_object__;
11571
+ }
11507
11572
  }
11508
11573
 
11509
11574
  async function registerProbes(probes) {