@interopio/browser 4.1.2 → 4.1.3

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.
@@ -7744,7 +7744,7 @@
7744
7744
  }
7745
7745
  }
7746
7746
 
7747
- var version$1 = "4.1.2";
7747
+ var version$1 = "4.1.3";
7748
7748
 
7749
7749
  const setupGlobalSystem = (io, bridge) => {
7750
7750
  return {
@@ -8031,7 +8031,10 @@
8031
8031
  type: "define",
8032
8032
  metrics: [rootStateMetric],
8033
8033
  };
8034
- session.send(defineRootMetricsMsg);
8034
+ session.sendFireAndForget(defineRootMetricsMsg)
8035
+ .catch((err) => {
8036
+ config.logger.warn(`Failed to send define for root state metric: ${JSON.stringify(err)}`);
8037
+ });
8035
8038
  if (reconnect) {
8036
8039
  replayRepo(repo);
8037
8040
  }
@@ -8079,7 +8082,10 @@
8079
8082
  type: "define",
8080
8083
  metrics: [metric],
8081
8084
  };
8082
- session.send(createMetricsMsg);
8085
+ session.sendFireAndForget(createMetricsMsg)
8086
+ .catch((err) => {
8087
+ config.logger.warn(`Failed to send define for system state metric of ${system.name}: ${JSON.stringify(err)}`);
8088
+ });
8083
8089
  };
8084
8090
  const updateSystem = async (system, state) => {
8085
8091
  await joinPromise;
@@ -8094,7 +8100,10 @@
8094
8100
  timestamp: Date.now(),
8095
8101
  }],
8096
8102
  };
8097
- session.send(shadowedUpdateMetric);
8103
+ session.sendFireAndForget(shadowedUpdateMetric)
8104
+ .catch((err) => {
8105
+ config.logger.warn(`Failed to send update for system state metric of ${system.name}: ${JSON.stringify(err)}`);
8106
+ });
8098
8107
  const stateObj = composeMsgForRootStateMetric(system);
8099
8108
  const rootMetric = {
8100
8109
  type: "publish",
@@ -8108,7 +8117,10 @@
8108
8117
  timestamp: Date.now(),
8109
8118
  }],
8110
8119
  };
8111
- session.send(rootMetric);
8120
+ session.sendFireAndForget(rootMetric)
8121
+ .catch((err) => {
8122
+ config.logger.warn(`Failed to send update for root state metric of ${system.name}: ${JSON.stringify(err)}`);
8123
+ });
8112
8124
  };
8113
8125
  const createMetric = async (metric) => {
8114
8126
  const metricClone = cloneMetric(metric);
@@ -8118,7 +8130,10 @@
8118
8130
  type: "define",
8119
8131
  metrics: [m],
8120
8132
  };
8121
- session.send(createMetricsMsg);
8133
+ session.sendFireAndForget(createMetricsMsg)
8134
+ .catch((err) => {
8135
+ config.logger.warn(`Failed to send define for metric ${metric.name}: ${JSON.stringify(err)}`);
8136
+ });
8122
8137
  if (typeof metricClone.value !== "undefined") {
8123
8138
  updateMetricCore(metricClone);
8124
8139
  }
@@ -8139,7 +8154,10 @@
8139
8154
  timestamp: Date.now(),
8140
8155
  }],
8141
8156
  };
8142
- return session.sendFireAndForget(publishMetricsMsg);
8157
+ return session.sendFireAndForget(publishMetricsMsg)
8158
+ .catch((err) => {
8159
+ config.logger.warn(`Failed to publish metric ${metric.name}: ${JSON.stringify(err)}`);
8160
+ });
8143
8161
  }
8144
8162
  return Promise.resolve();
8145
8163
  };
@@ -9006,8 +9024,9 @@
9006
9024
  const pw = new PromiseWrapper();
9007
9025
  this.logger.debug(`initiating ws to ${this.settings.ws}...`);
9008
9026
  this.ws = new WebSocketConstructor(this.settings.ws ?? "");
9027
+ let wasOpen = false;
9009
9028
  this.ws.onerror = (err) => {
9010
- let reason = "";
9029
+ let reason;
9011
9030
  try {
9012
9031
  reason = JSON.stringify(err);
9013
9032
  }
@@ -9026,17 +9045,26 @@
9026
9045
  }
9027
9046
  this.logger.info(`ws error - reason: ${reason}`);
9028
9047
  pw.reject("error");
9048
+ if (wasOpen) {
9049
+ wasOpen = false;
9050
+ this.notifyForSocketState("error");
9051
+ }
9029
9052
  this.notifyStatusChanged(false, reason);
9030
9053
  };
9031
9054
  this.ws.onclose = (err) => {
9032
9055
  this.logger.info(`ws closed - code: ${err?.code} reason: ${err?.reason}`);
9033
9056
  pw.reject("closed");
9057
+ if (wasOpen) {
9058
+ wasOpen = false;
9059
+ this.notifyForSocketState("closed");
9060
+ }
9034
9061
  this.notifyStatusChanged(false);
9035
9062
  };
9036
9063
  this.ws.onopen = () => {
9037
9064
  this.startupTimer.mark("ws-opened");
9038
9065
  this.logger.info(`ws opened ${this.settings.identity?.application}`);
9039
9066
  pw.resolve();
9067
+ wasOpen = true;
9040
9068
  this.notifyStatusChanged(true);
9041
9069
  };
9042
9070
  this.ws.onmessage = (message) => {
@@ -9824,17 +9852,31 @@
9824
9852
  callbacks.execute("onJoined", wasReconnect);
9825
9853
  }
9826
9854
  function handleConnectionDisconnected() {
9827
- _connectionOn = false;
9828
9855
  logger.debug("connection is down");
9856
+ _connectionOn = false;
9829
9857
  isJoined = false;
9830
9858
  tryReconnecting = true;
9859
+ Object.keys(requestsMap).forEach(requestId => {
9860
+ const request = requestsMap[requestId];
9861
+ if (request) {
9862
+ logger.trace(`failing pending request ${requestId} due to connection lost`);
9863
+ request.error({
9864
+ err: "Connection lost - gateway connection was disconnected"
9865
+ });
9866
+ }
9867
+ });
9831
9868
  callbacks.execute("onLeft", { disconnected: true });
9832
9869
  }
9833
- function handleConnectionLoggedIn() {
9870
+ async function handleConnectionLoggedIn() {
9834
9871
  _connectionOn = true;
9835
9872
  if (tryReconnecting) {
9836
9873
  logger.debug("connection is now up - trying to reconnect...");
9837
- join(_latestOptions);
9874
+ try {
9875
+ await join(_latestOptions);
9876
+ }
9877
+ catch {
9878
+ logger.trace(`failed to reconnect`);
9879
+ }
9838
9880
  }
9839
9881
  }
9840
9882
  function onJoined(callback) {
@@ -9927,7 +9969,7 @@
9927
9969
  connection
9928
9970
  .send(msg, options)
9929
9971
  .catch((err) => {
9930
- requestsMap[requestId].error({ err });
9972
+ requestsMap[requestId]?.error({ err });
9931
9973
  });
9932
9974
  });
9933
9975
  }
@@ -10006,6 +10048,7 @@
10006
10048
  initialLogin = true;
10007
10049
  initialLoginAttempts = 3;
10008
10050
  loginConfig;
10051
+ loginRetryInProgress = false;
10009
10052
  constructor(settings, logger) {
10010
10053
  this.settings = settings;
10011
10054
  this.logger = logger;
@@ -10119,6 +10162,7 @@
10119
10162
  return this.registry.add("disconnected", callback);
10120
10163
  }
10121
10164
  async login(authRequest, reconnect) {
10165
+ this.logger.debug(`Login initiated - reconnect: ${reconnect}, transport: ${this.transport.name()}`);
10122
10166
  if (!this._defaultAuth) {
10123
10167
  this._defaultAuth = authRequest;
10124
10168
  }
@@ -10127,19 +10171,18 @@
10127
10171
  const newAuth = this.transportSwap();
10128
10172
  authRequest = newAuth ?? authRequest;
10129
10173
  }
10130
- this.logger.trace(`Starting login for transport: ${this.transport.name()} and auth ${JSON.stringify(authRequest)}`);
10131
10174
  try {
10132
10175
  await this.transport.open();
10133
- this.logger.trace(`Transport: ${this.transport.name()} opened, logging in`);
10176
+ this.logger.debug(`Transport: ${this.transport.name()} opened, logging in`);
10134
10177
  timer("connection").mark("transport-opened");
10135
10178
  const identity = await this.loginCore(authRequest, reconnect);
10136
- this.logger.trace(`Logged in with identity: ${JSON.stringify(identity)}`);
10179
+ this.logger.debug(`Logged in with identity: ${JSON.stringify(identity)}`);
10137
10180
  timer("connection").mark("protocol-logged-in");
10138
10181
  return identity;
10139
10182
  }
10140
10183
  catch (error) {
10141
10184
  if (this._switchInProgress) {
10142
- this.logger.trace("An error while logging in after a transport swap, preparing a default swap.");
10185
+ this.logger.debug("An error while logging in after a transport swap, preparing a default swap.");
10143
10186
  this.prepareDefaultSwap();
10144
10187
  }
10145
10188
  throw new Error(error);
@@ -10182,6 +10225,7 @@
10182
10225
  setLoggedIn(value) {
10183
10226
  this._isLoggedIn = value;
10184
10227
  if (this._isLoggedIn) {
10228
+ this.initialLogin = false;
10185
10229
  this.registry.execute("onLoggedIn");
10186
10230
  }
10187
10231
  }
@@ -10208,8 +10252,10 @@
10208
10252
  }
10209
10253
  handleConnectionChanged(connected) {
10210
10254
  if (this._connected === connected) {
10255
+ this.logger.trace("connection state unchanged, skipping");
10211
10256
  return;
10212
10257
  }
10258
+ this.logger.info(`connection state changed to ${connected ? "connected" : "disconnected"}`);
10213
10259
  this._connected = connected;
10214
10260
  if (connected) {
10215
10261
  if (this.settings?.replaySpecs?.length) {
@@ -10219,28 +10265,44 @@
10219
10265
  this.registry.execute("connected");
10220
10266
  }
10221
10267
  else {
10222
- this.handleDisconnected();
10268
+ this.setLoggedIn(false);
10269
+ if (this.shouldTryLogin) {
10270
+ this.attemptLoginWithRetry();
10271
+ }
10223
10272
  this.registry.execute("disconnected");
10224
10273
  }
10225
10274
  }
10226
- handleDisconnected() {
10227
- this.setLoggedIn(false);
10228
- const tryToLogin = this.shouldTryLogin;
10229
- if (tryToLogin && this.initialLogin) {
10275
+ async attemptLoginWithRetry() {
10276
+ if (!this.loginConfig) {
10277
+ throw new Error("no login info");
10278
+ }
10279
+ if (this.loginRetryInProgress) {
10280
+ this.logger.debug("login attempt already in progress, ignoring request...");
10281
+ return;
10282
+ }
10283
+ if (this._isLoggedIn) {
10284
+ this.logger.debug("already logged in, ignoring request...");
10285
+ return;
10286
+ }
10287
+ if (this.initialLogin) {
10288
+ this.logger.debug(`initial login attempt failed, ${this.initialLoginAttempts} attempts remaining...`);
10230
10289
  if (this.initialLoginAttempts <= 0) {
10290
+ this.logger.info("maximum initial login attempts reached, will not try to login again");
10231
10291
  return;
10232
10292
  }
10233
10293
  this.initialLoginAttempts--;
10234
10294
  }
10235
- this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
10236
- if (this.shouldTryLogin) {
10237
- if (!this.loginConfig) {
10238
- throw new Error("no login info");
10239
- }
10240
- this.login(this.loginConfig, true)
10241
- .catch(() => {
10242
- setTimeout(this.handleDisconnected.bind(this), this.settings.reconnectInterval || 1000);
10243
- });
10295
+ try {
10296
+ this.logger.debug(`will try a new login... ${this.loginRetryInProgress}`);
10297
+ this.loginRetryInProgress = true;
10298
+ await this.login(this.loginConfig, true);
10299
+ }
10300
+ catch (e) {
10301
+ this.logger.error(`error trying to login: ${e?.message}`, e);
10302
+ setTimeout(this.attemptLoginWithRetry.bind(this), this.settings.reconnectInterval ?? 1000);
10303
+ }
10304
+ finally {
10305
+ this.loginRetryInProgress = false;
10244
10306
  }
10245
10307
  }
10246
10308
  handleTransportMessage(msg) {
@@ -10367,7 +10429,6 @@
10367
10429
  return message;
10368
10430
  }
10369
10431
  async loginCore(config, reconnect) {
10370
- this.logger.info("logging in...");
10371
10432
  this.loginConfig = config;
10372
10433
  if (!this.loginConfig) {
10373
10434
  this.loginConfig = { username: "", password: "" };
@@ -10382,11 +10443,13 @@
10382
10443
  if (config.sessionId) {
10383
10444
  helloMsg.request_id = config.sessionId;
10384
10445
  }
10385
- this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
10386
- "welcome",
10387
- "token",
10388
- "authentication-request"
10389
- ]);
10446
+ if (!this.globalDomain) {
10447
+ this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
10448
+ "welcome",
10449
+ "token",
10450
+ "authentication-request"
10451
+ ]);
10452
+ }
10390
10453
  const sendOptions = { skipPeerId: true };
10391
10454
  if (this.initialLogin) {
10392
10455
  sendOptions.retryInterval = this.settings.reconnectInterval;
@@ -10394,7 +10457,6 @@
10394
10457
  }
10395
10458
  try {
10396
10459
  const welcomeMsg = await this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config);
10397
- this.initialLogin = false;
10398
10460
  this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
10399
10461
  this.peerId = welcomeMsg.peer_id;
10400
10462
  this.resolvedIdentity = welcomeMsg.resolved_identity;
@@ -10497,7 +10559,7 @@
10497
10559
  clearTimeout(this.pingTimer);
10498
10560
  }
10499
10561
  const promises = this.sessions.map((session) => {
10500
- session.leave();
10562
+ return session.leave();
10501
10563
  });
10502
10564
  await Promise.all(promises);
10503
10565
  }
@@ -10722,7 +10784,7 @@
10722
10784
  }
10723
10785
  };
10724
10786
 
10725
- var version = "6.7.0";
10787
+ var version = "6.7.1";
10726
10788
 
10727
10789
  function prepareConfig (configuration, ext, glue42gd) {
10728
10790
  let nodeStartingContext;
@@ -12849,6 +12911,8 @@
12849
12911
  }
12850
12912
 
12851
12913
  class GW3Bridge {
12914
+ ERROR_URI_FAILURE = "global.errors.failure";
12915
+ ERROR_URI_INVALID_CONTEXT = "global.errors.invalid_context";
12852
12916
  _logger;
12853
12917
  _connection;
12854
12918
  _trackAllContexts;
@@ -12893,7 +12957,11 @@
12893
12957
  if (!this._reAnnounceKnownContexts) {
12894
12958
  return this._connection.setLibReAnnounced({ name: "contexts" });
12895
12959
  }
12896
- this.reInitiateState().then(() => this._connection.setLibReAnnounced({ name: "contexts" }));
12960
+ this.reInitiateState()
12961
+ .then(() => this._connection.setLibReAnnounced({ name: "contexts" }))
12962
+ .catch((err) => {
12963
+ this._logger.warn(`Error while re-announcing contexts: ${JSON.stringify(err)}`);
12964
+ });
12897
12965
  });
12898
12966
  this.subscribeToContextCreatedMessages();
12899
12967
  this.subscribeToContextUpdatedMessages();
@@ -12971,7 +13039,8 @@
12971
13039
  }
12972
13040
  const contextData = this._contextNameToData[name];
12973
13041
  if (!contextData || !contextData.isAnnounced) {
12974
- return this.createContext(name, delta);
13042
+ await this.createContext(name, delta);
13043
+ return;
12975
13044
  }
12976
13045
  let currentContext = contextData.context;
12977
13046
  if (!contextData.hasCallbacks()) {
@@ -13088,16 +13157,26 @@
13088
13157
  return Promise.resolve({});
13089
13158
  }
13090
13159
  if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
13091
- return new Promise((resolve) => {
13160
+ return new Promise((resolve, reject) => {
13092
13161
  this.subscribe(name, (data, _d, _r, un) => {
13093
13162
  this.unsubscribe(un);
13094
13163
  resolve(data);
13164
+ }).catch((e) => {
13165
+ if (this.isInvalidContextError(e)) {
13166
+ resolve({});
13167
+ return;
13168
+ }
13169
+ reject(e);
13095
13170
  });
13096
13171
  });
13097
13172
  }
13098
13173
  const context = contextData?.context ?? {};
13099
13174
  return Promise.resolve(deepClone(context));
13100
13175
  }
13176
+ isInvalidContextError(e) {
13177
+ return e.reason_uri === this.ERROR_URI_INVALID_CONTEXT
13178
+ || (e.reason_uri === this.ERROR_URI_FAILURE && e.reason?.startsWith("Unable to find context with id"));
13179
+ }
13101
13180
  async subscribe(name, callback, subscriptionKey) {
13102
13181
  if (name in this._creationPromises) {
13103
13182
  await this._creationPromises[name];
@@ -13181,7 +13260,7 @@
13181
13260
  type: GW_MESSAGE_DESTROY_CONTEXT,
13182
13261
  domain: "global",
13183
13262
  context_id: contextData.contextId,
13184
- }).then((_) => undefined);
13263
+ }).then(() => undefined);
13185
13264
  }
13186
13265
  handleUpdated(contextData, delta, extraData) {
13187
13266
  const oldContext = contextData.context;
@@ -13234,7 +13313,7 @@
13234
13313
  contextData.contextId = contextCreatedMsg.context_id;
13235
13314
  contextData.activityId = contextCreatedMsg.activity_id;
13236
13315
  if (!contextData.sentExplicitSubscription) {
13237
- this.sendSubscribe(contextData);
13316
+ this.sendSubscribe(contextData).catch(() => { });
13238
13317
  }
13239
13318
  }
13240
13319
  }
@@ -13386,16 +13465,25 @@
13386
13465
  type: GW_MESSAGE_SUBSCRIBE_CONTEXT,
13387
13466
  domain: "global",
13388
13467
  context_id: contextData.contextId,
13389
- }).then((_) => undefined);
13468
+ })
13469
+ .then(() => undefined)
13470
+ .catch(() => {
13471
+ contextData.sentExplicitSubscription = false;
13472
+ });
13390
13473
  }
13391
13474
  sendUnsubscribe(contextData) {
13475
+ const prev = contextData.sentExplicitSubscription;
13392
13476
  contextData.sentExplicitSubscription = false;
13393
13477
  return this._gw3Session
13394
13478
  .send({
13395
13479
  type: GW_MESSAGE_UNSUBSCRIBE_CONTEXT,
13396
13480
  domain: "global",
13397
13481
  context_id: contextData.contextId,
13398
- }).then((_) => undefined);
13482
+ })
13483
+ .then(() => undefined)
13484
+ .catch(() => {
13485
+ contextData.sentExplicitSubscription = prev;
13486
+ });
13399
13487
  }
13400
13488
  calculateContextDeltaV1(from, to) {
13401
13489
  const delta = { added: {}, updated: {}, removed: [], reset: undefined };
@@ -15638,13 +15726,15 @@
15638
15726
  session;
15639
15727
  repository;
15640
15728
  serverRepository;
15729
+ logger;
15641
15730
  ERR_URI_SUBSCRIPTION_FAILED = "com.tick42.agm.errors.subscription.failure";
15642
15731
  callbacks = CallbackRegistryFactory();
15643
15732
  nextStreamId = 0;
15644
- constructor(session, repository, serverRepository) {
15733
+ constructor(session, repository, serverRepository, logger) {
15645
15734
  this.session = session;
15646
15735
  this.repository = repository;
15647
15736
  this.serverRepository = serverRepository;
15737
+ this.logger = logger;
15648
15738
  session.on("add-interest", (msg) => {
15649
15739
  this.handleAddInterest(msg);
15650
15740
  });
@@ -15677,6 +15767,8 @@
15677
15767
  type: "accepted",
15678
15768
  subscription_id: key,
15679
15769
  stream_id: streamId,
15770
+ }).catch((err) => {
15771
+ this.logger.warn(`Failed to send accepted message for subscription ${key}: ${JSON.stringify(err)}`);
15680
15772
  });
15681
15773
  this.callbacks.execute(SUBSCRIPTION_ADDED, subscription, streamingMethod);
15682
15774
  }
@@ -15714,7 +15806,10 @@
15714
15806
  stream_id: streamId,
15715
15807
  data,
15716
15808
  };
15717
- this.session.sendFireAndForget(publishMessage);
15809
+ this.session.sendFireAndForget(publishMessage)
15810
+ .catch((err) => {
15811
+ this.logger.warn(`Failed to send publish message for stream ${streamId}: ${JSON.stringify(err)}`);
15812
+ });
15718
15813
  });
15719
15814
  }
15720
15815
  pushDataToSingle(method, subscription, data) {
@@ -15726,7 +15821,10 @@
15726
15821
  subscription_id: subscription.id,
15727
15822
  data,
15728
15823
  };
15729
- this.session.sendFireAndForget(postMessage);
15824
+ this.session.sendFireAndForget(postMessage)
15825
+ .catch((err) => {
15826
+ this.logger.warn(`Failed to send post message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
15827
+ });
15730
15828
  }
15731
15829
  closeSingleSubscription(streamingMethod, subscription) {
15732
15830
  if (streamingMethod.protocolState.subscriptionsMap) {
@@ -15737,7 +15835,10 @@
15737
15835
  subscription_id: subscription.id,
15738
15836
  reason: "Server dropping a single subscription",
15739
15837
  };
15740
- this.session.sendFireAndForget(dropSubscriptionMessage);
15838
+ this.session.sendFireAndForget(dropSubscriptionMessage)
15839
+ .catch((err) => {
15840
+ this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
15841
+ });
15741
15842
  subscription.instance;
15742
15843
  this.callbacks.execute(SUBSCRIPTION_REMOVED, subscription, streamingMethod);
15743
15844
  }
@@ -15765,7 +15866,10 @@
15765
15866
  subscription_id: subscription.id,
15766
15867
  reason: "Server dropping all subscriptions on stream_id: " + subscription.streamId,
15767
15868
  };
15768
- this.session.sendFireAndForget(drop);
15869
+ this.session.sendFireAndForget(drop)
15870
+ .catch((err) => {
15871
+ this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
15872
+ });
15769
15873
  });
15770
15874
  }
15771
15875
  getSubscriptionList(streamingMethod, branchKey) {
@@ -15874,7 +15978,10 @@
15874
15978
  reason,
15875
15979
  request_id: subscriptionId,
15876
15980
  };
15877
- this.session.sendFireAndForget(errorMessage);
15981
+ this.session.sendFireAndForget(errorMessage)
15982
+ .catch((err) => {
15983
+ this.logger.warn(`Failed to send subscription failed message for subscription ${subscriptionId}: ${JSON.stringify(err)}`);
15984
+ });
15878
15985
  }
15879
15986
  getStreamId(streamingMethod, branchKey) {
15880
15987
  if (typeof branchKey !== "string") {
@@ -15907,7 +16014,7 @@
15907
16014
  this.clientRepository = clientRepository;
15908
16015
  this.serverRepository = serverRepository;
15909
16016
  this.logger = logger;
15910
- this.streaming = new ServerStreaming(session, clientRepository, serverRepository);
16017
+ this.streaming = new ServerStreaming(session, clientRepository, serverRepository, logger.subLogger("streaming"));
15911
16018
  this.session.on("invoke", (msg) => this.handleInvokeMessage(msg));
15912
16019
  }
15913
16020
  createStream(repoMethod) {
@@ -15966,7 +16073,10 @@
15966
16073
  request_id: undefined,
15967
16074
  };
15968
16075
  }
15969
- this.session.sendFireAndForget(msg);
16076
+ this.session.sendFireAndForget(msg)
16077
+ .catch((error => {
16078
+ this.logger.warn(`Failed to send method invocation result for method ${method.definition.name} invocation ${invocationId} - ${JSON.stringify(error)}`);
16079
+ }));
15970
16080
  }
15971
16081
  async unregister(method) {
15972
16082
  const msg = {
@@ -16426,6 +16536,8 @@
16426
16536
  subscription_id: server.subscriptionId,
16427
16537
  reason_uri: "",
16428
16538
  reason: ON_CLOSE_MSG_CLIENT_INIT,
16539
+ }).catch((err) => {
16540
+ this.logger.warn(`Error sending unsubscribe for subscription id ${server.subscriptionId}: ${JSON.stringify(err)}`);
16429
16541
  });
16430
16542
  delete this.subscriptionIdToLocalKeyMap[server.subscriptionId];
16431
16543
  });
@@ -16765,7 +16877,10 @@
16765
16877
  routing_key: routingKey,
16766
16878
  target_identity: target
16767
16879
  });
16768
- this.session.send(args);
16880
+ this.session.send(args)
16881
+ .catch((err) => {
16882
+ this.logger.error(`Failed to publish message to topic ${topic} with routing key ${routingKey} for ${JSON.stringify(target)}: ${JSON.stringify(err)}`);
16883
+ });
16769
16884
  };
16770
16885
  subscribe = (topic, callback, options) => {
16771
16886
  return new Promise((resolve, reject) => {
@@ -16783,8 +16898,12 @@
16783
16898
  this.subscriptions.push({ subscription_id, topic, callback, source: target });
16784
16899
  resolve({
16785
16900
  unsubscribe: () => {
16786
- this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId });
16787
- this.subscriptions = this.subscriptions.filter((s) => s.subscription_id !== subscription_id);
16901
+ this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId })
16902
+ .then(() => {
16903
+ this.subscriptions = this.subscriptions.filter((s) => s.subscription_id !== subscription_id);
16904
+ }).catch((err) => {
16905
+ this.logger.warn(`Failed to send unsubscribe request for ${subscription_id}: ${JSON.stringify(err)}`);
16906
+ });
16788
16907
  return Promise.resolve();
16789
16908
  }
16790
16909
  });