@interopio/browser 4.1.1 → 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.
@@ -2623,6 +2623,13 @@ const resolverConfigDecoder = object$2({
2623
2623
  appName: nonEmptyStringDecoder$2,
2624
2624
  waitResponseTimeout: number$2()
2625
2625
  });
2626
+ const handlerExclusionCriteriaApplicationNameDecoder = object$2({
2627
+ applicationName: nonEmptyStringDecoder$2
2628
+ });
2629
+ const handlerExclusionCriteriaInstanceIdDecoder = object$2({
2630
+ instanceId: nonEmptyStringDecoder$2
2631
+ });
2632
+ const handlerExclusionCriteriaDecoder = oneOf$1(handlerExclusionCriteriaApplicationNameDecoder, handlerExclusionCriteriaInstanceIdDecoder);
2626
2633
  const handlerFilterDecoder = object$2({
2627
2634
  title: optional$2(nonEmptyStringDecoder$2),
2628
2635
  openResolver: optional$2(boolean$2()),
@@ -2630,7 +2637,8 @@ const handlerFilterDecoder = object$2({
2630
2637
  intent: optional$2(nonEmptyStringDecoder$2),
2631
2638
  contextTypes: optional$2(array$2(nonEmptyStringDecoder$2)),
2632
2639
  resultType: optional$2(nonEmptyStringDecoder$2),
2633
- applicationNames: optional$2(array$2(nonEmptyStringDecoder$2))
2640
+ applicationNames: optional$2(array$2(nonEmptyStringDecoder$2)),
2641
+ excludeList: optional$2(array$2(handlerExclusionCriteriaDecoder))
2634
2642
  });
2635
2643
  const embeddedResolverConfigDecoder = object$2({
2636
2644
  enabled: boolean$2(),
@@ -7730,7 +7738,7 @@ class IoC {
7730
7738
  }
7731
7739
  }
7732
7740
 
7733
- var version$1 = "4.1.1";
7741
+ var version$1 = "4.1.3";
7734
7742
 
7735
7743
  const setupGlobalSystem = (io, bridge) => {
7736
7744
  return {
@@ -8017,7 +8025,10 @@ function gw3 (connection, config) {
8017
8025
  type: "define",
8018
8026
  metrics: [rootStateMetric],
8019
8027
  };
8020
- 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
+ });
8021
8032
  if (reconnect) {
8022
8033
  replayRepo(repo);
8023
8034
  }
@@ -8065,7 +8076,10 @@ function gw3 (connection, config) {
8065
8076
  type: "define",
8066
8077
  metrics: [metric],
8067
8078
  };
8068
- 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
+ });
8069
8083
  };
8070
8084
  const updateSystem = async (system, state) => {
8071
8085
  await joinPromise;
@@ -8080,7 +8094,10 @@ function gw3 (connection, config) {
8080
8094
  timestamp: Date.now(),
8081
8095
  }],
8082
8096
  };
8083
- 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
+ });
8084
8101
  const stateObj = composeMsgForRootStateMetric(system);
8085
8102
  const rootMetric = {
8086
8103
  type: "publish",
@@ -8094,7 +8111,10 @@ function gw3 (connection, config) {
8094
8111
  timestamp: Date.now(),
8095
8112
  }],
8096
8113
  };
8097
- 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
+ });
8098
8118
  };
8099
8119
  const createMetric = async (metric) => {
8100
8120
  const metricClone = cloneMetric(metric);
@@ -8104,7 +8124,10 @@ function gw3 (connection, config) {
8104
8124
  type: "define",
8105
8125
  metrics: [m],
8106
8126
  };
8107
- 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
+ });
8108
8131
  if (typeof metricClone.value !== "undefined") {
8109
8132
  updateMetricCore(metricClone);
8110
8133
  }
@@ -8125,7 +8148,10 @@ function gw3 (connection, config) {
8125
8148
  timestamp: Date.now(),
8126
8149
  }],
8127
8150
  };
8128
- 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
+ });
8129
8155
  }
8130
8156
  return Promise.resolve();
8131
8157
  };
@@ -8992,8 +9018,9 @@ class WS {
8992
9018
  const pw = new PromiseWrapper();
8993
9019
  this.logger.debug(`initiating ws to ${this.settings.ws}...`);
8994
9020
  this.ws = new WebSocketConstructor(this.settings.ws ?? "");
9021
+ let wasOpen = false;
8995
9022
  this.ws.onerror = (err) => {
8996
- let reason = "";
9023
+ let reason;
8997
9024
  try {
8998
9025
  reason = JSON.stringify(err);
8999
9026
  }
@@ -9012,17 +9039,26 @@ class WS {
9012
9039
  }
9013
9040
  this.logger.info(`ws error - reason: ${reason}`);
9014
9041
  pw.reject("error");
9042
+ if (wasOpen) {
9043
+ wasOpen = false;
9044
+ this.notifyForSocketState("error");
9045
+ }
9015
9046
  this.notifyStatusChanged(false, reason);
9016
9047
  };
9017
9048
  this.ws.onclose = (err) => {
9018
9049
  this.logger.info(`ws closed - code: ${err?.code} reason: ${err?.reason}`);
9019
9050
  pw.reject("closed");
9051
+ if (wasOpen) {
9052
+ wasOpen = false;
9053
+ this.notifyForSocketState("closed");
9054
+ }
9020
9055
  this.notifyStatusChanged(false);
9021
9056
  };
9022
9057
  this.ws.onopen = () => {
9023
9058
  this.startupTimer.mark("ws-opened");
9024
9059
  this.logger.info(`ws opened ${this.settings.identity?.application}`);
9025
9060
  pw.resolve();
9061
+ wasOpen = true;
9026
9062
  this.notifyStatusChanged(true);
9027
9063
  };
9028
9064
  this.ws.onmessage = (message) => {
@@ -9810,17 +9846,31 @@ function domainSession (domain, connection, logger, successMessages, errorMessag
9810
9846
  callbacks.execute("onJoined", wasReconnect);
9811
9847
  }
9812
9848
  function handleConnectionDisconnected() {
9813
- _connectionOn = false;
9814
9849
  logger.debug("connection is down");
9850
+ _connectionOn = false;
9815
9851
  isJoined = false;
9816
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
+ });
9817
9862
  callbacks.execute("onLeft", { disconnected: true });
9818
9863
  }
9819
- function handleConnectionLoggedIn() {
9864
+ async function handleConnectionLoggedIn() {
9820
9865
  _connectionOn = true;
9821
9866
  if (tryReconnecting) {
9822
9867
  logger.debug("connection is now up - trying to reconnect...");
9823
- join(_latestOptions);
9868
+ try {
9869
+ await join(_latestOptions);
9870
+ }
9871
+ catch {
9872
+ logger.trace(`failed to reconnect`);
9873
+ }
9824
9874
  }
9825
9875
  }
9826
9876
  function onJoined(callback) {
@@ -9913,7 +9963,7 @@ function domainSession (domain, connection, logger, successMessages, errorMessag
9913
9963
  connection
9914
9964
  .send(msg, options)
9915
9965
  .catch((err) => {
9916
- requestsMap[requestId].error({ err });
9966
+ requestsMap[requestId]?.error({ err });
9917
9967
  });
9918
9968
  });
9919
9969
  }
@@ -9992,6 +10042,7 @@ class Connection {
9992
10042
  initialLogin = true;
9993
10043
  initialLoginAttempts = 3;
9994
10044
  loginConfig;
10045
+ loginRetryInProgress = false;
9995
10046
  constructor(settings, logger) {
9996
10047
  this.settings = settings;
9997
10048
  this.logger = logger;
@@ -10105,6 +10156,7 @@ class Connection {
10105
10156
  return this.registry.add("disconnected", callback);
10106
10157
  }
10107
10158
  async login(authRequest, reconnect) {
10159
+ this.logger.debug(`Login initiated - reconnect: ${reconnect}, transport: ${this.transport.name()}`);
10108
10160
  if (!this._defaultAuth) {
10109
10161
  this._defaultAuth = authRequest;
10110
10162
  }
@@ -10113,19 +10165,18 @@ class Connection {
10113
10165
  const newAuth = this.transportSwap();
10114
10166
  authRequest = newAuth ?? authRequest;
10115
10167
  }
10116
- this.logger.trace(`Starting login for transport: ${this.transport.name()} and auth ${JSON.stringify(authRequest)}`);
10117
10168
  try {
10118
10169
  await this.transport.open();
10119
- this.logger.trace(`Transport: ${this.transport.name()} opened, logging in`);
10170
+ this.logger.debug(`Transport: ${this.transport.name()} opened, logging in`);
10120
10171
  timer("connection").mark("transport-opened");
10121
10172
  const identity = await this.loginCore(authRequest, reconnect);
10122
- this.logger.trace(`Logged in with identity: ${JSON.stringify(identity)}`);
10173
+ this.logger.debug(`Logged in with identity: ${JSON.stringify(identity)}`);
10123
10174
  timer("connection").mark("protocol-logged-in");
10124
10175
  return identity;
10125
10176
  }
10126
10177
  catch (error) {
10127
10178
  if (this._switchInProgress) {
10128
- 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.");
10129
10180
  this.prepareDefaultSwap();
10130
10181
  }
10131
10182
  throw new Error(error);
@@ -10168,6 +10219,7 @@ class Connection {
10168
10219
  setLoggedIn(value) {
10169
10220
  this._isLoggedIn = value;
10170
10221
  if (this._isLoggedIn) {
10222
+ this.initialLogin = false;
10171
10223
  this.registry.execute("onLoggedIn");
10172
10224
  }
10173
10225
  }
@@ -10194,8 +10246,10 @@ class Connection {
10194
10246
  }
10195
10247
  handleConnectionChanged(connected) {
10196
10248
  if (this._connected === connected) {
10249
+ this.logger.trace("connection state unchanged, skipping");
10197
10250
  return;
10198
10251
  }
10252
+ this.logger.info(`connection state changed to ${connected ? "connected" : "disconnected"}`);
10199
10253
  this._connected = connected;
10200
10254
  if (connected) {
10201
10255
  if (this.settings?.replaySpecs?.length) {
@@ -10205,28 +10259,44 @@ class Connection {
10205
10259
  this.registry.execute("connected");
10206
10260
  }
10207
10261
  else {
10208
- this.handleDisconnected();
10262
+ this.setLoggedIn(false);
10263
+ if (this.shouldTryLogin) {
10264
+ this.attemptLoginWithRetry();
10265
+ }
10209
10266
  this.registry.execute("disconnected");
10210
10267
  }
10211
10268
  }
10212
- handleDisconnected() {
10213
- this.setLoggedIn(false);
10214
- const tryToLogin = this.shouldTryLogin;
10215
- 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...`);
10216
10283
  if (this.initialLoginAttempts <= 0) {
10284
+ this.logger.info("maximum initial login attempts reached, will not try to login again");
10217
10285
  return;
10218
10286
  }
10219
10287
  this.initialLoginAttempts--;
10220
10288
  }
10221
- this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
10222
- if (this.shouldTryLogin) {
10223
- if (!this.loginConfig) {
10224
- throw new Error("no login info");
10225
- }
10226
- this.login(this.loginConfig, true)
10227
- .catch(() => {
10228
- setTimeout(this.handleDisconnected.bind(this), this.settings.reconnectInterval || 1000);
10229
- });
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;
10230
10300
  }
10231
10301
  }
10232
10302
  handleTransportMessage(msg) {
@@ -10353,7 +10423,6 @@ class Connection {
10353
10423
  return message;
10354
10424
  }
10355
10425
  async loginCore(config, reconnect) {
10356
- this.logger.info("logging in...");
10357
10426
  this.loginConfig = config;
10358
10427
  if (!this.loginConfig) {
10359
10428
  this.loginConfig = { username: "", password: "" };
@@ -10368,11 +10437,13 @@ class Connection {
10368
10437
  if (config.sessionId) {
10369
10438
  helloMsg.request_id = config.sessionId;
10370
10439
  }
10371
- this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
10372
- "welcome",
10373
- "token",
10374
- "authentication-request"
10375
- ]);
10440
+ if (!this.globalDomain) {
10441
+ this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
10442
+ "welcome",
10443
+ "token",
10444
+ "authentication-request"
10445
+ ]);
10446
+ }
10376
10447
  const sendOptions = { skipPeerId: true };
10377
10448
  if (this.initialLogin) {
10378
10449
  sendOptions.retryInterval = this.settings.reconnectInterval;
@@ -10380,7 +10451,6 @@ class Connection {
10380
10451
  }
10381
10452
  try {
10382
10453
  const welcomeMsg = await this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config);
10383
- this.initialLogin = false;
10384
10454
  this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
10385
10455
  this.peerId = welcomeMsg.peer_id;
10386
10456
  this.resolvedIdentity = welcomeMsg.resolved_identity;
@@ -10483,7 +10553,7 @@ class Connection {
10483
10553
  clearTimeout(this.pingTimer);
10484
10554
  }
10485
10555
  const promises = this.sessions.map((session) => {
10486
- session.leave();
10556
+ return session.leave();
10487
10557
  });
10488
10558
  await Promise.all(promises);
10489
10559
  }
@@ -10708,7 +10778,7 @@ const ContextMessageReplaySpec = {
10708
10778
  }
10709
10779
  };
10710
10780
 
10711
- var version = "6.7.0";
10781
+ var version = "6.7.1";
10712
10782
 
10713
10783
  function prepareConfig (configuration, ext, glue42gd) {
10714
10784
  let nodeStartingContext;
@@ -12835,6 +12905,8 @@ function deletePath(obj, path) {
12835
12905
  }
12836
12906
 
12837
12907
  class GW3Bridge {
12908
+ ERROR_URI_FAILURE = "global.errors.failure";
12909
+ ERROR_URI_INVALID_CONTEXT = "global.errors.invalid_context";
12838
12910
  _logger;
12839
12911
  _connection;
12840
12912
  _trackAllContexts;
@@ -12879,7 +12951,11 @@ class GW3Bridge {
12879
12951
  if (!this._reAnnounceKnownContexts) {
12880
12952
  return this._connection.setLibReAnnounced({ name: "contexts" });
12881
12953
  }
12882
- 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
+ });
12883
12959
  });
12884
12960
  this.subscribeToContextCreatedMessages();
12885
12961
  this.subscribeToContextUpdatedMessages();
@@ -12957,7 +13033,8 @@ class GW3Bridge {
12957
13033
  }
12958
13034
  const contextData = this._contextNameToData[name];
12959
13035
  if (!contextData || !contextData.isAnnounced) {
12960
- return this.createContext(name, delta);
13036
+ await this.createContext(name, delta);
13037
+ return;
12961
13038
  }
12962
13039
  let currentContext = contextData.context;
12963
13040
  if (!contextData.hasCallbacks()) {
@@ -13074,16 +13151,26 @@ class GW3Bridge {
13074
13151
  return Promise.resolve({});
13075
13152
  }
13076
13153
  if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
13077
- return new Promise((resolve) => {
13154
+ return new Promise((resolve, reject) => {
13078
13155
  this.subscribe(name, (data, _d, _r, un) => {
13079
13156
  this.unsubscribe(un);
13080
13157
  resolve(data);
13158
+ }).catch((e) => {
13159
+ if (this.isInvalidContextError(e)) {
13160
+ resolve({});
13161
+ return;
13162
+ }
13163
+ reject(e);
13081
13164
  });
13082
13165
  });
13083
13166
  }
13084
13167
  const context = contextData?.context ?? {};
13085
13168
  return Promise.resolve(deepClone(context));
13086
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
+ }
13087
13174
  async subscribe(name, callback, subscriptionKey) {
13088
13175
  if (name in this._creationPromises) {
13089
13176
  await this._creationPromises[name];
@@ -13167,7 +13254,7 @@ class GW3Bridge {
13167
13254
  type: GW_MESSAGE_DESTROY_CONTEXT,
13168
13255
  domain: "global",
13169
13256
  context_id: contextData.contextId,
13170
- }).then((_) => undefined);
13257
+ }).then(() => undefined);
13171
13258
  }
13172
13259
  handleUpdated(contextData, delta, extraData) {
13173
13260
  const oldContext = contextData.context;
@@ -13220,7 +13307,7 @@ class GW3Bridge {
13220
13307
  contextData.contextId = contextCreatedMsg.context_id;
13221
13308
  contextData.activityId = contextCreatedMsg.activity_id;
13222
13309
  if (!contextData.sentExplicitSubscription) {
13223
- this.sendSubscribe(contextData);
13310
+ this.sendSubscribe(contextData).catch(() => { });
13224
13311
  }
13225
13312
  }
13226
13313
  }
@@ -13372,16 +13459,25 @@ class GW3Bridge {
13372
13459
  type: GW_MESSAGE_SUBSCRIBE_CONTEXT,
13373
13460
  domain: "global",
13374
13461
  context_id: contextData.contextId,
13375
- }).then((_) => undefined);
13462
+ })
13463
+ .then(() => undefined)
13464
+ .catch(() => {
13465
+ contextData.sentExplicitSubscription = false;
13466
+ });
13376
13467
  }
13377
13468
  sendUnsubscribe(contextData) {
13469
+ const prev = contextData.sentExplicitSubscription;
13378
13470
  contextData.sentExplicitSubscription = false;
13379
13471
  return this._gw3Session
13380
13472
  .send({
13381
13473
  type: GW_MESSAGE_UNSUBSCRIBE_CONTEXT,
13382
13474
  domain: "global",
13383
13475
  context_id: contextData.contextId,
13384
- }).then((_) => undefined);
13476
+ })
13477
+ .then(() => undefined)
13478
+ .catch(() => {
13479
+ contextData.sentExplicitSubscription = prev;
13480
+ });
13385
13481
  }
13386
13482
  calculateContextDeltaV1(from, to) {
13387
13483
  const delta = { added: {}, updated: {}, removed: [], reset: undefined };
@@ -15624,13 +15720,15 @@ class ServerStreaming {
15624
15720
  session;
15625
15721
  repository;
15626
15722
  serverRepository;
15723
+ logger;
15627
15724
  ERR_URI_SUBSCRIPTION_FAILED = "com.tick42.agm.errors.subscription.failure";
15628
15725
  callbacks = CallbackRegistryFactory();
15629
15726
  nextStreamId = 0;
15630
- constructor(session, repository, serverRepository) {
15727
+ constructor(session, repository, serverRepository, logger) {
15631
15728
  this.session = session;
15632
15729
  this.repository = repository;
15633
15730
  this.serverRepository = serverRepository;
15731
+ this.logger = logger;
15634
15732
  session.on("add-interest", (msg) => {
15635
15733
  this.handleAddInterest(msg);
15636
15734
  });
@@ -15663,6 +15761,8 @@ class ServerStreaming {
15663
15761
  type: "accepted",
15664
15762
  subscription_id: key,
15665
15763
  stream_id: streamId,
15764
+ }).catch((err) => {
15765
+ this.logger.warn(`Failed to send accepted message for subscription ${key}: ${JSON.stringify(err)}`);
15666
15766
  });
15667
15767
  this.callbacks.execute(SUBSCRIPTION_ADDED, subscription, streamingMethod);
15668
15768
  }
@@ -15700,7 +15800,10 @@ class ServerStreaming {
15700
15800
  stream_id: streamId,
15701
15801
  data,
15702
15802
  };
15703
- 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
+ });
15704
15807
  });
15705
15808
  }
15706
15809
  pushDataToSingle(method, subscription, data) {
@@ -15712,7 +15815,10 @@ class ServerStreaming {
15712
15815
  subscription_id: subscription.id,
15713
15816
  data,
15714
15817
  };
15715
- 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
+ });
15716
15822
  }
15717
15823
  closeSingleSubscription(streamingMethod, subscription) {
15718
15824
  if (streamingMethod.protocolState.subscriptionsMap) {
@@ -15723,7 +15829,10 @@ class ServerStreaming {
15723
15829
  subscription_id: subscription.id,
15724
15830
  reason: "Server dropping a single subscription",
15725
15831
  };
15726
- 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
+ });
15727
15836
  subscription.instance;
15728
15837
  this.callbacks.execute(SUBSCRIPTION_REMOVED, subscription, streamingMethod);
15729
15838
  }
@@ -15751,7 +15860,10 @@ class ServerStreaming {
15751
15860
  subscription_id: subscription.id,
15752
15861
  reason: "Server dropping all subscriptions on stream_id: " + subscription.streamId,
15753
15862
  };
15754
- 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
+ });
15755
15867
  });
15756
15868
  }
15757
15869
  getSubscriptionList(streamingMethod, branchKey) {
@@ -15860,7 +15972,10 @@ class ServerStreaming {
15860
15972
  reason,
15861
15973
  request_id: subscriptionId,
15862
15974
  };
15863
- 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
+ });
15864
15979
  }
15865
15980
  getStreamId(streamingMethod, branchKey) {
15866
15981
  if (typeof branchKey !== "string") {
@@ -15893,7 +16008,7 @@ class ServerProtocol {
15893
16008
  this.clientRepository = clientRepository;
15894
16009
  this.serverRepository = serverRepository;
15895
16010
  this.logger = logger;
15896
- this.streaming = new ServerStreaming(session, clientRepository, serverRepository);
16011
+ this.streaming = new ServerStreaming(session, clientRepository, serverRepository, logger.subLogger("streaming"));
15897
16012
  this.session.on("invoke", (msg) => this.handleInvokeMessage(msg));
15898
16013
  }
15899
16014
  createStream(repoMethod) {
@@ -15952,7 +16067,10 @@ class ServerProtocol {
15952
16067
  request_id: undefined,
15953
16068
  };
15954
16069
  }
15955
- 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
+ }));
15956
16074
  }
15957
16075
  async unregister(method) {
15958
16076
  const msg = {
@@ -16412,6 +16530,8 @@ class ClientStreaming {
16412
16530
  subscription_id: server.subscriptionId,
16413
16531
  reason_uri: "",
16414
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)}`);
16415
16535
  });
16416
16536
  delete this.subscriptionIdToLocalKeyMap[server.subscriptionId];
16417
16537
  });
@@ -16751,7 +16871,10 @@ class MessageBus {
16751
16871
  routing_key: routingKey,
16752
16872
  target_identity: target
16753
16873
  });
16754
- 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
+ });
16755
16878
  };
16756
16879
  subscribe = (topic, callback, options) => {
16757
16880
  return new Promise((resolve, reject) => {
@@ -16769,8 +16892,12 @@ class MessageBus {
16769
16892
  this.subscriptions.push({ subscription_id, topic, callback, source: target });
16770
16893
  resolve({
16771
16894
  unsubscribe: () => {
16772
- this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId });
16773
- 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
+ });
16774
16901
  return Promise.resolve();
16775
16902
  }
16776
16903
  });