@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.
@@ -7738,7 +7738,7 @@ class IoC {
7738
7738
  }
7739
7739
  }
7740
7740
 
7741
- var version$1 = "4.1.2";
7741
+ var version$1 = "4.1.3";
7742
7742
 
7743
7743
  const setupGlobalSystem = (io, bridge) => {
7744
7744
  return {
@@ -8025,7 +8025,10 @@ function gw3 (connection, config) {
8025
8025
  type: "define",
8026
8026
  metrics: [rootStateMetric],
8027
8027
  };
8028
- session.send(defineRootMetricsMsg);
8028
+ session.sendFireAndForget(defineRootMetricsMsg)
8029
+ .catch((err) => {
8030
+ config.logger.warn(`Failed to send define for root state metric: ${JSON.stringify(err)}`);
8031
+ });
8029
8032
  if (reconnect) {
8030
8033
  replayRepo(repo);
8031
8034
  }
@@ -8073,7 +8076,10 @@ function gw3 (connection, config) {
8073
8076
  type: "define",
8074
8077
  metrics: [metric],
8075
8078
  };
8076
- session.send(createMetricsMsg);
8079
+ session.sendFireAndForget(createMetricsMsg)
8080
+ .catch((err) => {
8081
+ config.logger.warn(`Failed to send define for system state metric of ${system.name}: ${JSON.stringify(err)}`);
8082
+ });
8077
8083
  };
8078
8084
  const updateSystem = async (system, state) => {
8079
8085
  await joinPromise;
@@ -8088,7 +8094,10 @@ function gw3 (connection, config) {
8088
8094
  timestamp: Date.now(),
8089
8095
  }],
8090
8096
  };
8091
- session.send(shadowedUpdateMetric);
8097
+ session.sendFireAndForget(shadowedUpdateMetric)
8098
+ .catch((err) => {
8099
+ config.logger.warn(`Failed to send update for system state metric of ${system.name}: ${JSON.stringify(err)}`);
8100
+ });
8092
8101
  const stateObj = composeMsgForRootStateMetric(system);
8093
8102
  const rootMetric = {
8094
8103
  type: "publish",
@@ -8102,7 +8111,10 @@ function gw3 (connection, config) {
8102
8111
  timestamp: Date.now(),
8103
8112
  }],
8104
8113
  };
8105
- session.send(rootMetric);
8114
+ session.sendFireAndForget(rootMetric)
8115
+ .catch((err) => {
8116
+ config.logger.warn(`Failed to send update for root state metric of ${system.name}: ${JSON.stringify(err)}`);
8117
+ });
8106
8118
  };
8107
8119
  const createMetric = async (metric) => {
8108
8120
  const metricClone = cloneMetric(metric);
@@ -8112,7 +8124,10 @@ function gw3 (connection, config) {
8112
8124
  type: "define",
8113
8125
  metrics: [m],
8114
8126
  };
8115
- session.send(createMetricsMsg);
8127
+ session.sendFireAndForget(createMetricsMsg)
8128
+ .catch((err) => {
8129
+ config.logger.warn(`Failed to send define for metric ${metric.name}: ${JSON.stringify(err)}`);
8130
+ });
8116
8131
  if (typeof metricClone.value !== "undefined") {
8117
8132
  updateMetricCore(metricClone);
8118
8133
  }
@@ -8133,7 +8148,10 @@ function gw3 (connection, config) {
8133
8148
  timestamp: Date.now(),
8134
8149
  }],
8135
8150
  };
8136
- return session.sendFireAndForget(publishMetricsMsg);
8151
+ return session.sendFireAndForget(publishMetricsMsg)
8152
+ .catch((err) => {
8153
+ config.logger.warn(`Failed to publish metric ${metric.name}: ${JSON.stringify(err)}`);
8154
+ });
8137
8155
  }
8138
8156
  return Promise.resolve();
8139
8157
  };
@@ -9000,8 +9018,9 @@ class WS {
9000
9018
  const pw = new PromiseWrapper();
9001
9019
  this.logger.debug(`initiating ws to ${this.settings.ws}...`);
9002
9020
  this.ws = new WebSocketConstructor(this.settings.ws ?? "");
9021
+ let wasOpen = false;
9003
9022
  this.ws.onerror = (err) => {
9004
- let reason = "";
9023
+ let reason;
9005
9024
  try {
9006
9025
  reason = JSON.stringify(err);
9007
9026
  }
@@ -9020,17 +9039,26 @@ class WS {
9020
9039
  }
9021
9040
  this.logger.info(`ws error - reason: ${reason}`);
9022
9041
  pw.reject("error");
9042
+ if (wasOpen) {
9043
+ wasOpen = false;
9044
+ this.notifyForSocketState("error");
9045
+ }
9023
9046
  this.notifyStatusChanged(false, reason);
9024
9047
  };
9025
9048
  this.ws.onclose = (err) => {
9026
9049
  this.logger.info(`ws closed - code: ${err?.code} reason: ${err?.reason}`);
9027
9050
  pw.reject("closed");
9051
+ if (wasOpen) {
9052
+ wasOpen = false;
9053
+ this.notifyForSocketState("closed");
9054
+ }
9028
9055
  this.notifyStatusChanged(false);
9029
9056
  };
9030
9057
  this.ws.onopen = () => {
9031
9058
  this.startupTimer.mark("ws-opened");
9032
9059
  this.logger.info(`ws opened ${this.settings.identity?.application}`);
9033
9060
  pw.resolve();
9061
+ wasOpen = true;
9034
9062
  this.notifyStatusChanged(true);
9035
9063
  };
9036
9064
  this.ws.onmessage = (message) => {
@@ -9818,17 +9846,31 @@ function domainSession (domain, connection, logger, successMessages, errorMessag
9818
9846
  callbacks.execute("onJoined", wasReconnect);
9819
9847
  }
9820
9848
  function handleConnectionDisconnected() {
9821
- _connectionOn = false;
9822
9849
  logger.debug("connection is down");
9850
+ _connectionOn = false;
9823
9851
  isJoined = false;
9824
9852
  tryReconnecting = true;
9853
+ Object.keys(requestsMap).forEach(requestId => {
9854
+ const request = requestsMap[requestId];
9855
+ if (request) {
9856
+ logger.trace(`failing pending request ${requestId} due to connection lost`);
9857
+ request.error({
9858
+ err: "Connection lost - gateway connection was disconnected"
9859
+ });
9860
+ }
9861
+ });
9825
9862
  callbacks.execute("onLeft", { disconnected: true });
9826
9863
  }
9827
- function handleConnectionLoggedIn() {
9864
+ async function handleConnectionLoggedIn() {
9828
9865
  _connectionOn = true;
9829
9866
  if (tryReconnecting) {
9830
9867
  logger.debug("connection is now up - trying to reconnect...");
9831
- join(_latestOptions);
9868
+ try {
9869
+ await join(_latestOptions);
9870
+ }
9871
+ catch {
9872
+ logger.trace(`failed to reconnect`);
9873
+ }
9832
9874
  }
9833
9875
  }
9834
9876
  function onJoined(callback) {
@@ -9921,7 +9963,7 @@ function domainSession (domain, connection, logger, successMessages, errorMessag
9921
9963
  connection
9922
9964
  .send(msg, options)
9923
9965
  .catch((err) => {
9924
- requestsMap[requestId].error({ err });
9966
+ requestsMap[requestId]?.error({ err });
9925
9967
  });
9926
9968
  });
9927
9969
  }
@@ -10000,6 +10042,7 @@ class Connection {
10000
10042
  initialLogin = true;
10001
10043
  initialLoginAttempts = 3;
10002
10044
  loginConfig;
10045
+ loginRetryInProgress = false;
10003
10046
  constructor(settings, logger) {
10004
10047
  this.settings = settings;
10005
10048
  this.logger = logger;
@@ -10113,6 +10156,7 @@ class Connection {
10113
10156
  return this.registry.add("disconnected", callback);
10114
10157
  }
10115
10158
  async login(authRequest, reconnect) {
10159
+ this.logger.debug(`Login initiated - reconnect: ${reconnect}, transport: ${this.transport.name()}`);
10116
10160
  if (!this._defaultAuth) {
10117
10161
  this._defaultAuth = authRequest;
10118
10162
  }
@@ -10121,19 +10165,18 @@ class Connection {
10121
10165
  const newAuth = this.transportSwap();
10122
10166
  authRequest = newAuth ?? authRequest;
10123
10167
  }
10124
- this.logger.trace(`Starting login for transport: ${this.transport.name()} and auth ${JSON.stringify(authRequest)}`);
10125
10168
  try {
10126
10169
  await this.transport.open();
10127
- this.logger.trace(`Transport: ${this.transport.name()} opened, logging in`);
10170
+ this.logger.debug(`Transport: ${this.transport.name()} opened, logging in`);
10128
10171
  timer("connection").mark("transport-opened");
10129
10172
  const identity = await this.loginCore(authRequest, reconnect);
10130
- this.logger.trace(`Logged in with identity: ${JSON.stringify(identity)}`);
10173
+ this.logger.debug(`Logged in with identity: ${JSON.stringify(identity)}`);
10131
10174
  timer("connection").mark("protocol-logged-in");
10132
10175
  return identity;
10133
10176
  }
10134
10177
  catch (error) {
10135
10178
  if (this._switchInProgress) {
10136
- this.logger.trace("An error while logging in after a transport swap, preparing a default swap.");
10179
+ this.logger.debug("An error while logging in after a transport swap, preparing a default swap.");
10137
10180
  this.prepareDefaultSwap();
10138
10181
  }
10139
10182
  throw new Error(error);
@@ -10176,6 +10219,7 @@ class Connection {
10176
10219
  setLoggedIn(value) {
10177
10220
  this._isLoggedIn = value;
10178
10221
  if (this._isLoggedIn) {
10222
+ this.initialLogin = false;
10179
10223
  this.registry.execute("onLoggedIn");
10180
10224
  }
10181
10225
  }
@@ -10202,8 +10246,10 @@ class Connection {
10202
10246
  }
10203
10247
  handleConnectionChanged(connected) {
10204
10248
  if (this._connected === connected) {
10249
+ this.logger.trace("connection state unchanged, skipping");
10205
10250
  return;
10206
10251
  }
10252
+ this.logger.info(`connection state changed to ${connected ? "connected" : "disconnected"}`);
10207
10253
  this._connected = connected;
10208
10254
  if (connected) {
10209
10255
  if (this.settings?.replaySpecs?.length) {
@@ -10213,28 +10259,44 @@ class Connection {
10213
10259
  this.registry.execute("connected");
10214
10260
  }
10215
10261
  else {
10216
- this.handleDisconnected();
10262
+ this.setLoggedIn(false);
10263
+ if (this.shouldTryLogin) {
10264
+ this.attemptLoginWithRetry();
10265
+ }
10217
10266
  this.registry.execute("disconnected");
10218
10267
  }
10219
10268
  }
10220
- handleDisconnected() {
10221
- this.setLoggedIn(false);
10222
- const tryToLogin = this.shouldTryLogin;
10223
- if (tryToLogin && this.initialLogin) {
10269
+ async attemptLoginWithRetry() {
10270
+ if (!this.loginConfig) {
10271
+ throw new Error("no login info");
10272
+ }
10273
+ if (this.loginRetryInProgress) {
10274
+ this.logger.debug("login attempt already in progress, ignoring request...");
10275
+ return;
10276
+ }
10277
+ if (this._isLoggedIn) {
10278
+ this.logger.debug("already logged in, ignoring request...");
10279
+ return;
10280
+ }
10281
+ if (this.initialLogin) {
10282
+ this.logger.debug(`initial login attempt failed, ${this.initialLoginAttempts} attempts remaining...`);
10224
10283
  if (this.initialLoginAttempts <= 0) {
10284
+ this.logger.info("maximum initial login attempts reached, will not try to login again");
10225
10285
  return;
10226
10286
  }
10227
10287
  this.initialLoginAttempts--;
10228
10288
  }
10229
- this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
10230
- if (this.shouldTryLogin) {
10231
- if (!this.loginConfig) {
10232
- throw new Error("no login info");
10233
- }
10234
- this.login(this.loginConfig, true)
10235
- .catch(() => {
10236
- setTimeout(this.handleDisconnected.bind(this), this.settings.reconnectInterval || 1000);
10237
- });
10289
+ try {
10290
+ this.logger.debug(`will try a new login... ${this.loginRetryInProgress}`);
10291
+ this.loginRetryInProgress = true;
10292
+ await this.login(this.loginConfig, true);
10293
+ }
10294
+ catch (e) {
10295
+ this.logger.error(`error trying to login: ${e?.message}`, e);
10296
+ setTimeout(this.attemptLoginWithRetry.bind(this), this.settings.reconnectInterval ?? 1000);
10297
+ }
10298
+ finally {
10299
+ this.loginRetryInProgress = false;
10238
10300
  }
10239
10301
  }
10240
10302
  handleTransportMessage(msg) {
@@ -10361,7 +10423,6 @@ class Connection {
10361
10423
  return message;
10362
10424
  }
10363
10425
  async loginCore(config, reconnect) {
10364
- this.logger.info("logging in...");
10365
10426
  this.loginConfig = config;
10366
10427
  if (!this.loginConfig) {
10367
10428
  this.loginConfig = { username: "", password: "" };
@@ -10376,11 +10437,13 @@ class Connection {
10376
10437
  if (config.sessionId) {
10377
10438
  helloMsg.request_id = config.sessionId;
10378
10439
  }
10379
- this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
10380
- "welcome",
10381
- "token",
10382
- "authentication-request"
10383
- ]);
10440
+ if (!this.globalDomain) {
10441
+ this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
10442
+ "welcome",
10443
+ "token",
10444
+ "authentication-request"
10445
+ ]);
10446
+ }
10384
10447
  const sendOptions = { skipPeerId: true };
10385
10448
  if (this.initialLogin) {
10386
10449
  sendOptions.retryInterval = this.settings.reconnectInterval;
@@ -10388,7 +10451,6 @@ class Connection {
10388
10451
  }
10389
10452
  try {
10390
10453
  const welcomeMsg = await this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config);
10391
- this.initialLogin = false;
10392
10454
  this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
10393
10455
  this.peerId = welcomeMsg.peer_id;
10394
10456
  this.resolvedIdentity = welcomeMsg.resolved_identity;
@@ -10491,7 +10553,7 @@ class Connection {
10491
10553
  clearTimeout(this.pingTimer);
10492
10554
  }
10493
10555
  const promises = this.sessions.map((session) => {
10494
- session.leave();
10556
+ return session.leave();
10495
10557
  });
10496
10558
  await Promise.all(promises);
10497
10559
  }
@@ -10716,7 +10778,7 @@ const ContextMessageReplaySpec = {
10716
10778
  }
10717
10779
  };
10718
10780
 
10719
- var version = "6.7.0";
10781
+ var version = "6.7.1";
10720
10782
 
10721
10783
  function prepareConfig (configuration, ext, glue42gd) {
10722
10784
  let nodeStartingContext;
@@ -12843,6 +12905,8 @@ function deletePath(obj, path) {
12843
12905
  }
12844
12906
 
12845
12907
  class GW3Bridge {
12908
+ ERROR_URI_FAILURE = "global.errors.failure";
12909
+ ERROR_URI_INVALID_CONTEXT = "global.errors.invalid_context";
12846
12910
  _logger;
12847
12911
  _connection;
12848
12912
  _trackAllContexts;
@@ -12887,7 +12951,11 @@ class GW3Bridge {
12887
12951
  if (!this._reAnnounceKnownContexts) {
12888
12952
  return this._connection.setLibReAnnounced({ name: "contexts" });
12889
12953
  }
12890
- this.reInitiateState().then(() => this._connection.setLibReAnnounced({ name: "contexts" }));
12954
+ this.reInitiateState()
12955
+ .then(() => this._connection.setLibReAnnounced({ name: "contexts" }))
12956
+ .catch((err) => {
12957
+ this._logger.warn(`Error while re-announcing contexts: ${JSON.stringify(err)}`);
12958
+ });
12891
12959
  });
12892
12960
  this.subscribeToContextCreatedMessages();
12893
12961
  this.subscribeToContextUpdatedMessages();
@@ -12965,7 +13033,8 @@ class GW3Bridge {
12965
13033
  }
12966
13034
  const contextData = this._contextNameToData[name];
12967
13035
  if (!contextData || !contextData.isAnnounced) {
12968
- return this.createContext(name, delta);
13036
+ await this.createContext(name, delta);
13037
+ return;
12969
13038
  }
12970
13039
  let currentContext = contextData.context;
12971
13040
  if (!contextData.hasCallbacks()) {
@@ -13082,16 +13151,26 @@ class GW3Bridge {
13082
13151
  return Promise.resolve({});
13083
13152
  }
13084
13153
  if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
13085
- return new Promise((resolve) => {
13154
+ return new Promise((resolve, reject) => {
13086
13155
  this.subscribe(name, (data, _d, _r, un) => {
13087
13156
  this.unsubscribe(un);
13088
13157
  resolve(data);
13158
+ }).catch((e) => {
13159
+ if (this.isInvalidContextError(e)) {
13160
+ resolve({});
13161
+ return;
13162
+ }
13163
+ reject(e);
13089
13164
  });
13090
13165
  });
13091
13166
  }
13092
13167
  const context = contextData?.context ?? {};
13093
13168
  return Promise.resolve(deepClone(context));
13094
13169
  }
13170
+ isInvalidContextError(e) {
13171
+ return e.reason_uri === this.ERROR_URI_INVALID_CONTEXT
13172
+ || (e.reason_uri === this.ERROR_URI_FAILURE && e.reason?.startsWith("Unable to find context with id"));
13173
+ }
13095
13174
  async subscribe(name, callback, subscriptionKey) {
13096
13175
  if (name in this._creationPromises) {
13097
13176
  await this._creationPromises[name];
@@ -13175,7 +13254,7 @@ class GW3Bridge {
13175
13254
  type: GW_MESSAGE_DESTROY_CONTEXT,
13176
13255
  domain: "global",
13177
13256
  context_id: contextData.contextId,
13178
- }).then((_) => undefined);
13257
+ }).then(() => undefined);
13179
13258
  }
13180
13259
  handleUpdated(contextData, delta, extraData) {
13181
13260
  const oldContext = contextData.context;
@@ -13228,7 +13307,7 @@ class GW3Bridge {
13228
13307
  contextData.contextId = contextCreatedMsg.context_id;
13229
13308
  contextData.activityId = contextCreatedMsg.activity_id;
13230
13309
  if (!contextData.sentExplicitSubscription) {
13231
- this.sendSubscribe(contextData);
13310
+ this.sendSubscribe(contextData).catch(() => { });
13232
13311
  }
13233
13312
  }
13234
13313
  }
@@ -13380,16 +13459,25 @@ class GW3Bridge {
13380
13459
  type: GW_MESSAGE_SUBSCRIBE_CONTEXT,
13381
13460
  domain: "global",
13382
13461
  context_id: contextData.contextId,
13383
- }).then((_) => undefined);
13462
+ })
13463
+ .then(() => undefined)
13464
+ .catch(() => {
13465
+ contextData.sentExplicitSubscription = false;
13466
+ });
13384
13467
  }
13385
13468
  sendUnsubscribe(contextData) {
13469
+ const prev = contextData.sentExplicitSubscription;
13386
13470
  contextData.sentExplicitSubscription = false;
13387
13471
  return this._gw3Session
13388
13472
  .send({
13389
13473
  type: GW_MESSAGE_UNSUBSCRIBE_CONTEXT,
13390
13474
  domain: "global",
13391
13475
  context_id: contextData.contextId,
13392
- }).then((_) => undefined);
13476
+ })
13477
+ .then(() => undefined)
13478
+ .catch(() => {
13479
+ contextData.sentExplicitSubscription = prev;
13480
+ });
13393
13481
  }
13394
13482
  calculateContextDeltaV1(from, to) {
13395
13483
  const delta = { added: {}, updated: {}, removed: [], reset: undefined };
@@ -15632,13 +15720,15 @@ class ServerStreaming {
15632
15720
  session;
15633
15721
  repository;
15634
15722
  serverRepository;
15723
+ logger;
15635
15724
  ERR_URI_SUBSCRIPTION_FAILED = "com.tick42.agm.errors.subscription.failure";
15636
15725
  callbacks = CallbackRegistryFactory();
15637
15726
  nextStreamId = 0;
15638
- constructor(session, repository, serverRepository) {
15727
+ constructor(session, repository, serverRepository, logger) {
15639
15728
  this.session = session;
15640
15729
  this.repository = repository;
15641
15730
  this.serverRepository = serverRepository;
15731
+ this.logger = logger;
15642
15732
  session.on("add-interest", (msg) => {
15643
15733
  this.handleAddInterest(msg);
15644
15734
  });
@@ -15671,6 +15761,8 @@ class ServerStreaming {
15671
15761
  type: "accepted",
15672
15762
  subscription_id: key,
15673
15763
  stream_id: streamId,
15764
+ }).catch((err) => {
15765
+ this.logger.warn(`Failed to send accepted message for subscription ${key}: ${JSON.stringify(err)}`);
15674
15766
  });
15675
15767
  this.callbacks.execute(SUBSCRIPTION_ADDED, subscription, streamingMethod);
15676
15768
  }
@@ -15708,7 +15800,10 @@ class ServerStreaming {
15708
15800
  stream_id: streamId,
15709
15801
  data,
15710
15802
  };
15711
- this.session.sendFireAndForget(publishMessage);
15803
+ this.session.sendFireAndForget(publishMessage)
15804
+ .catch((err) => {
15805
+ this.logger.warn(`Failed to send publish message for stream ${streamId}: ${JSON.stringify(err)}`);
15806
+ });
15712
15807
  });
15713
15808
  }
15714
15809
  pushDataToSingle(method, subscription, data) {
@@ -15720,7 +15815,10 @@ class ServerStreaming {
15720
15815
  subscription_id: subscription.id,
15721
15816
  data,
15722
15817
  };
15723
- this.session.sendFireAndForget(postMessage);
15818
+ this.session.sendFireAndForget(postMessage)
15819
+ .catch((err) => {
15820
+ this.logger.warn(`Failed to send post message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
15821
+ });
15724
15822
  }
15725
15823
  closeSingleSubscription(streamingMethod, subscription) {
15726
15824
  if (streamingMethod.protocolState.subscriptionsMap) {
@@ -15731,7 +15829,10 @@ class ServerStreaming {
15731
15829
  subscription_id: subscription.id,
15732
15830
  reason: "Server dropping a single subscription",
15733
15831
  };
15734
- this.session.sendFireAndForget(dropSubscriptionMessage);
15832
+ this.session.sendFireAndForget(dropSubscriptionMessage)
15833
+ .catch((err) => {
15834
+ this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
15835
+ });
15735
15836
  subscription.instance;
15736
15837
  this.callbacks.execute(SUBSCRIPTION_REMOVED, subscription, streamingMethod);
15737
15838
  }
@@ -15759,7 +15860,10 @@ class ServerStreaming {
15759
15860
  subscription_id: subscription.id,
15760
15861
  reason: "Server dropping all subscriptions on stream_id: " + subscription.streamId,
15761
15862
  };
15762
- this.session.sendFireAndForget(drop);
15863
+ this.session.sendFireAndForget(drop)
15864
+ .catch((err) => {
15865
+ this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
15866
+ });
15763
15867
  });
15764
15868
  }
15765
15869
  getSubscriptionList(streamingMethod, branchKey) {
@@ -15868,7 +15972,10 @@ class ServerStreaming {
15868
15972
  reason,
15869
15973
  request_id: subscriptionId,
15870
15974
  };
15871
- this.session.sendFireAndForget(errorMessage);
15975
+ this.session.sendFireAndForget(errorMessage)
15976
+ .catch((err) => {
15977
+ this.logger.warn(`Failed to send subscription failed message for subscription ${subscriptionId}: ${JSON.stringify(err)}`);
15978
+ });
15872
15979
  }
15873
15980
  getStreamId(streamingMethod, branchKey) {
15874
15981
  if (typeof branchKey !== "string") {
@@ -15901,7 +16008,7 @@ class ServerProtocol {
15901
16008
  this.clientRepository = clientRepository;
15902
16009
  this.serverRepository = serverRepository;
15903
16010
  this.logger = logger;
15904
- this.streaming = new ServerStreaming(session, clientRepository, serverRepository);
16011
+ this.streaming = new ServerStreaming(session, clientRepository, serverRepository, logger.subLogger("streaming"));
15905
16012
  this.session.on("invoke", (msg) => this.handleInvokeMessage(msg));
15906
16013
  }
15907
16014
  createStream(repoMethod) {
@@ -15960,7 +16067,10 @@ class ServerProtocol {
15960
16067
  request_id: undefined,
15961
16068
  };
15962
16069
  }
15963
- this.session.sendFireAndForget(msg);
16070
+ this.session.sendFireAndForget(msg)
16071
+ .catch((error => {
16072
+ this.logger.warn(`Failed to send method invocation result for method ${method.definition.name} invocation ${invocationId} - ${JSON.stringify(error)}`);
16073
+ }));
15964
16074
  }
15965
16075
  async unregister(method) {
15966
16076
  const msg = {
@@ -16420,6 +16530,8 @@ class ClientStreaming {
16420
16530
  subscription_id: server.subscriptionId,
16421
16531
  reason_uri: "",
16422
16532
  reason: ON_CLOSE_MSG_CLIENT_INIT,
16533
+ }).catch((err) => {
16534
+ this.logger.warn(`Error sending unsubscribe for subscription id ${server.subscriptionId}: ${JSON.stringify(err)}`);
16423
16535
  });
16424
16536
  delete this.subscriptionIdToLocalKeyMap[server.subscriptionId];
16425
16537
  });
@@ -16759,7 +16871,10 @@ class MessageBus {
16759
16871
  routing_key: routingKey,
16760
16872
  target_identity: target
16761
16873
  });
16762
- this.session.send(args);
16874
+ this.session.send(args)
16875
+ .catch((err) => {
16876
+ this.logger.error(`Failed to publish message to topic ${topic} with routing key ${routingKey} for ${JSON.stringify(target)}: ${JSON.stringify(err)}`);
16877
+ });
16763
16878
  };
16764
16879
  subscribe = (topic, callback, options) => {
16765
16880
  return new Promise((resolve, reject) => {
@@ -16777,8 +16892,12 @@ class MessageBus {
16777
16892
  this.subscriptions.push({ subscription_id, topic, callback, source: target });
16778
16893
  resolve({
16779
16894
  unsubscribe: () => {
16780
- this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId });
16781
- this.subscriptions = this.subscriptions.filter((s) => s.subscription_id !== subscription_id);
16895
+ this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId })
16896
+ .then(() => {
16897
+ this.subscriptions = this.subscriptions.filter((s) => s.subscription_id !== subscription_id);
16898
+ }).catch((err) => {
16899
+ this.logger.warn(`Failed to send unsubscribe request for ${subscription_id}: ${JSON.stringify(err)}`);
16900
+ });
16782
16901
  return Promise.resolve();
16783
16902
  }
16784
16903
  });