hypha-rpc 0.21.32 → 0.21.34

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-06T00:02:24.136Z
89
+ at 2026-02-10T16:00:13.893Z
90
90
  </div>
91
91
  <script src="prettify.js"></script>
92
92
  <script>
@@ -4002,10 +4002,12 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4002
4002
 
4003
4003
  try {
4004
4004
  // Get fresh manager service (one RPC roundtrip, ~50-100ms)
4005
+ const _t0 = Date.now();
4005
4006
  const manager = await this.get_manager_service({
4006
4007
  timeout: 20,
4007
4008
  case_conversion: "camel",
4008
4009
  });
4010
+ console.error(`[DEBUG] get_manager_service took ${Date.now() - _t0}ms`);
4009
4011
 
4010
4012
  // Fire manager_refreshed IMMEDIATELY — before service re-registration.
4011
4013
  // This allows connectToServer's wm proxy to be updated as soon as
@@ -4030,12 +4032,14 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4030
4032
  continue;
4031
4033
  }
4032
4034
  try {
4035
+ const _t1 = Date.now();
4033
4036
  const serviceInfo = this._extract_service_info(service);
4034
4037
  await withTimeout(
4035
4038
  manager.registerService(serviceInfo),
4036
4039
  serviceRegistrationTimeout,
4037
4040
  `Timeout registering service ${service.id || "unknown"}`,
4038
4041
  );
4042
+ console.error(`[DEBUG] registerService(${service.id}) took ${Date.now() - _t1}ms`);
4039
4043
  registeredCount++;
4040
4044
  } catch (serviceError) {
4041
4045
  failedServices.push(service.id || "unknown");
@@ -4180,11 +4184,10 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4180
4184
  // This ensures no remote function call hangs forever when the connection drops
4181
4185
  if (typeof connection.on_disconnected === "function") {
4182
4186
  connection.on_disconnected((reason) => {
4183
- // If reconnection is enabled AND the connection is not permanently closed,
4184
- // don't reject pending calls immediately they may succeed after reconnect.
4185
- // When _closed is true (max retries exhausted or server refused reconnect),
4186
- // we must reject immediately so callers are not left hanging forever.
4187
- if (connection._enable_reconnect && !connection._closed) {
4187
+ // If reconnection is enabled, don't reject pending calls immediately.
4188
+ // The timeout mechanism will handle them if reconnection fails,
4189
+ // allowing calls to succeed after a successful reconnection.
4190
+ if (connection._enable_reconnect) {
4188
4191
  this._logger.info(
4189
4192
  `Connection lost (${reason}), reconnection enabled - pending calls will be handled by timeout`,
4190
4193
  );
@@ -4538,15 +4541,7 @@ class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
4538
4541
  delete this._rintfCallerIndex[clientId];
4539
4542
  let cleaned = 0;
4540
4543
  for (const sid of serviceIds) {
4541
- const svc = this._services[sid];
4542
- if (svc) {
4543
- if (typeof svc._dispose === "function") {
4544
- try {
4545
- svc._dispose();
4546
- } catch (e) {
4547
- /* ignore errors from dispose handlers */
4548
- }
4549
- }
4544
+ if (this._services[sid]) {
4550
4545
  delete this._services[sid];
4551
4546
  cleaned++;
4552
4547
  }
@@ -11064,7 +11059,9 @@ async function connectToServer(config) {
11064
11059
  config.ping_interval,
11065
11060
  config.logger,
11066
11061
  );
11062
+ const _tOpen = Date.now();
11067
11063
  const connection_info = await connection.open();
11064
+ console.error(`[DEBUG] connection.open() took ${Date.now() - _tOpen}ms`);
11068
11065
  (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_2__.assert)(
11069
11066
  connection_info,
11070
11067
  "Failed to connect to the server, no connection info obtained. This issue is most likely due to an outdated Hypha server version. Please use `imjoy-rpc` for compatibility, or upgrade the Hypha server to the latest version.",
@@ -11098,6 +11095,7 @@ async function connectToServer(config) {
11098
11095
  }
11099
11096
 
11100
11097
  const workspace = connection_info.workspace;
11098
+ const _tRpc = Date.now();
11101
11099
  const rpc = new _rpc_js__WEBPACK_IMPORTED_MODULE_0__.RPC(connection, {
11102
11100
  client_id: clientId,
11103
11101
  workspace,
@@ -11114,12 +11112,17 @@ async function connectToServer(config) {
11114
11112
  encryption_private_key: config.encryption_private_key || null,
11115
11113
  encryption_public_key: config.encryption_public_key || null,
11116
11114
  });
11115
+ console.error(`[DEBUG] RPC constructor took ${Date.now() - _tRpc}ms`);
11116
+ const _tWait = Date.now();
11117
11117
  await rpc.waitFor("services_registered", config.method_timeout || 120);
11118
+ console.error(`[DEBUG] waitFor('services_registered') took ${Date.now() - _tWait}ms`);
11119
+ const _tWm = Date.now();
11118
11120
  const wm = await rpc.get_manager_service({
11119
11121
  timeout: config.method_timeout,
11120
11122
  case_conversion: "camel",
11121
11123
  kwargs_expansion: config.kwargs_expansion || false,
11122
11124
  });
11125
+ console.error(`[DEBUG] get_manager_service (connectToServer) took ${Date.now() - _tWm}ms`);
11123
11126
  wm.rpc = rpc;
11124
11127
 
11125
11128
  // Auto-refresh workspace manager proxy after reconnection.