@openfin/remote-adapter 40.82.3 → 40.82.4

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.
Files changed (2) hide show
  1. package/out/remote-adapter.js +195 -46
  2. package/package.json +2 -2
@@ -4404,19 +4404,57 @@ transportErrors.NotImplementedError = NotImplementedError;
4404
4404
  class NotSupportedError extends Error {
4405
4405
  }
4406
4406
  transportErrors.NotSupportedError = NotSupportedError;
4407
- class InternalError extends Error {
4407
+ class DeserializedError extends Error {
4408
4408
  constructor(err) {
4409
4409
  const { message, name, stack, ...rest } = err;
4410
4410
  super(message);
4411
+ if ('cause' in err && err.cause) {
4412
+ this.cause = new DeserializedError(err.cause);
4413
+ }
4411
4414
  this.name = name || 'Error';
4412
4415
  this.stack = stack ?? this.toString();
4413
- Object.keys(rest).forEach(key => {
4416
+ Object.keys(rest)
4417
+ .filter((k) => k !== 'cause')
4418
+ .forEach((key) => {
4414
4419
  this[key] = rest[key];
4415
4420
  });
4416
4421
  }
4417
4422
  }
4418
4423
  // For documentation of the error methods being used see here: https://v8.dev/docs/stack-trace-api
4419
4424
  class RuntimeError extends Error {
4425
+ static trimEndCallSites(err, takeUntilRegex) {
4426
+ // save original props
4427
+ const length = Error.stackTraceLimit;
4428
+ // eslint-disable-next-line no-underscore-dangle
4429
+ const _prepareStackTrace = Error.prepareStackTrace;
4430
+ // This will be called when we access the `stack` property
4431
+ Error.prepareStackTrace = (_, stack) => stack;
4432
+ // in channel errors, the error was already serialized so we need to handle both string and CallSite[]
4433
+ const isString = typeof err.stack === 'string';
4434
+ const stack = (isString ? err.stack?.split('\n') : err.stack) ?? [];
4435
+ // restore original props
4436
+ Error.prepareStackTrace = _prepareStackTrace;
4437
+ Error.stackTraceLimit = length;
4438
+ // stack is optional in non chromium contexts
4439
+ if (stack.length) {
4440
+ const newStack = [];
4441
+ // remove this call ONLY if it's not a string
4442
+ for (const line of isString ? stack : stack.slice(1)) {
4443
+ // inclusive take until
4444
+ newStack.push(line);
4445
+ if (takeUntilRegex.test(line.toString())) {
4446
+ break;
4447
+ }
4448
+ }
4449
+ if (isString) {
4450
+ // maintain it as a string
4451
+ err.stack = newStack.join('\n');
4452
+ }
4453
+ else {
4454
+ err.stack = RuntimeError.prepareStackTrace(err, newStack);
4455
+ }
4456
+ }
4457
+ }
4420
4458
  static getCallSite(callsToRemove = 0) {
4421
4459
  const length = Error.stackTraceLimit;
4422
4460
  const realCallsToRemove = callsToRemove + 1; // remove this call;
@@ -4435,21 +4473,82 @@ class RuntimeError extends Error {
4435
4473
  if (typeof Error.prepareStackTrace === 'function') {
4436
4474
  return Error.prepareStackTrace(err, callSites);
4437
4475
  }
4438
- let string = "";
4439
- string += err.name || "Error";
4440
- string += `: ${err.message || ""}`;
4441
- for (const callSite of callSites) {
4442
- string += `\n at ${callSite.toString()}`;
4443
- }
4444
- return string;
4445
- }
4446
- ;
4476
+ // TODO: this is just a first iteration, we can make this "nicer" at some point
4477
+ // const EXCLUSIONS = ['IpcRenderer', 'Object.onMessage', 'Transport.onmessage', 'MessageReceiver.onmessage'];
4478
+ let stackTrace = `${err.name || 'Error'}: ${err.message || ''}\n`;
4479
+ stackTrace += callSites
4480
+ .map((line) => ` at ${line}`)
4481
+ // .filter((line) => !EXCLUSIONS.some((l) => line.includes(l)))
4482
+ .join('\n');
4483
+ return stackTrace;
4484
+ }
4485
+ /*
4486
+
4487
+ NON filtered stack trace example from MTP page channel-errors.tsx:
4488
+
4489
+ Caused by: ChannelError: Error from ch0
4490
+ at ChannelClient.dispatch (<anonymous>:3:119560)
4491
+ at eval (test-channel-errors.tsx:73:26)
4492
+ at ChannelProvider.processAction (<anonymous>:3:116748)
4493
+ at ChannelProvider.processAction (<anonymous>:3:149121)
4494
+ at MessageReceiver.processChannelMessage (<anonymous>:3:131909)
4495
+ at MessageReceiver.onmessage (<anonymous>:3:131232)
4496
+ at Transport.onmessage (<anonymous>:3:282049)
4497
+ at IpcRenderer.<anonymous> (<anonymous>:3:275150)
4498
+ at IpcRenderer.emit (node:electron/js2c/sandbox_bundle:2:34834)
4499
+ at Object.onMessage (node:electron/js2c/sandbox_bundle:2:51566)
4500
+ Caused by: ChannelError: Error from ch0
4501
+ at ChannelClient.dispatch (<anonymous>:3:119560)
4502
+ at eval (test-channel-errors.tsx:73:26)
4503
+ at ChannelProvider.processAction (<anonymous>:3:116748)
4504
+ at ChannelProvider.processAction (<anonymous>:3:149121)
4505
+ at MessageReceiver.processChannelMessage (<anonymous>:3:131909)
4506
+ at MessageReceiver.onmessage (<anonymous>:3:131232)
4507
+ at Transport.onmessage (<anonymous>:3:282049)
4508
+ at IpcRenderer.<anonymous> (<anonymous>:3:275150)
4509
+ at IpcRenderer.emit (node:electron/js2c/sandbox_bundle:2:34834)
4510
+ at Object.onMessage (node:electron/js2c/sandbox_bundle:2:51566)
4511
+ Caused by: ChannelError: Error from ch0
4512
+ at ChannelClient.dispatch (<anonymous>:3:119560)
4513
+ at eval (test-channel-errors.tsx:73:26)
4514
+ at ChannelProvider.processAction (<anonymous>:3:116748)
4515
+ at ChannelProvider.processAction (<anonymous>:3:149121)
4516
+ at MessageReceiver.processChannelMessage (<anonymous>:3:131909)
4517
+ at MessageReceiver.onmessage (<anonymous>:3:131232)
4518
+ at Transport.onmessage (<anonymous>:3:282049)
4519
+ at IpcRenderer.<anonymous> (<anonymous>:3:275150)
4520
+ at IpcRenderer.emit (node:electron/js2c/sandbox_bundle:2:34834)
4521
+ at Object.onMessage (node:electron/js2c/sandbox_bundle:2:51566)
4522
+ Caused by: ChannelError: Error from ch0
4523
+ at ChannelClient.dispatch (<anonymous>:3:119560)
4524
+ at eval (test-channel-errors.tsx:50:23)
4525
+ at ChannelProvider.processAction (<anonymous>:3:116748)
4526
+ at ChannelProvider.processAction (<anonymous>:3:149121)
4527
+ at MessageReceiver.processChannelMessage (<anonymous>:3:131909)
4528
+ at MessageReceiver.onmessage (<anonymous>:3:131232)
4529
+ at Transport.onmessage (<anonymous>:3:282049)
4530
+ at IpcRenderer.<anonymous> (<anonymous>:3:275150)
4531
+ at IpcRenderer.emit (node:electron/js2c/sandbox_bundle:2:34834)
4532
+ at Object.onMessage (node:electron/js2c/sandbox_bundle:2:51566)
4533
+ Caused by: Error: Error from ch0
4534
+ at eval (test-channel-errors.tsx:54:19)
4535
+ at ChannelProvider.processAction (<anonymous>:3:116748)
4536
+ at ChannelProvider.processAction (<anonymous>:3:149121)
4537
+ at MessageReceiver.processChannelMessage (<anonymous>:3:131909)
4538
+ at MessageReceiver.onmessage (<anonymous>:3:131232)
4539
+ at Transport.onmessage (<anonymous>:3:282049)
4540
+ at IpcRenderer.<anonymous> (<anonymous>:3:275150)
4541
+ at IpcRenderer.emit (node:electron/js2c/sandbox_bundle:2:34834)
4542
+ at Object.onMessage (node:electron/js2c/sandbox_bundle:2:51566)
4543
+
4544
+
4545
+ */
4447
4546
  constructor(payload, callSites) {
4448
4547
  const { reason, error } = payload;
4449
4548
  super(reason);
4450
- this.name = 'RuntimeError';
4549
+ this.name = this.constructor.name;
4451
4550
  if (error?.stack) {
4452
- this.cause = new InternalError(error);
4551
+ this.cause = new DeserializedError(error);
4453
4552
  }
4454
4553
  if (callSites) {
4455
4554
  this.stack = RuntimeError.prepareStackTrace(this, callSites);
@@ -9435,9 +9534,14 @@ function requireInstance () {
9435
9534
  // don't expose
9436
9535
  });
9437
9536
  const layoutWindow = await this.getCurrentWindow();
9537
+ let layoutWindowIdentity = layoutWindow.identity;
9538
+ // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
9539
+ if (layoutWindowIdentity.identity) {
9540
+ layoutWindowIdentity = layoutWindowIdentity.identity;
9541
+ }
9438
9542
  try {
9439
9543
  const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
9440
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
9544
+ const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindowIdentity);
9441
9545
  const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
9442
9546
  return this.fin.Platform.Layout.wrap(layoutIdentity);
9443
9547
  }
@@ -9450,7 +9554,7 @@ function requireInstance () {
9450
9554
  throw e;
9451
9555
  }
9452
9556
  // fallback logic for missing endpoint
9453
- return this.fin.Platform.Layout.wrap(layoutWindow.identity);
9557
+ return this.fin.Platform.Layout.wrap(layoutWindowIdentity);
9454
9558
  }
9455
9559
  };
9456
9560
  /**
@@ -10167,13 +10271,17 @@ var errors = {};
10167
10271
  Object.defineProperty(errors, "__esModule", { value: true });
10168
10272
  errors.errorToPOJO = void 0;
10169
10273
  function errorToPOJO(error) {
10170
- return {
10274
+ const errorObj = {
10171
10275
  stack: error.stack,
10172
10276
  name: error.name,
10173
10277
  message: error.message,
10174
10278
  // support the case where stack is empty or missing
10175
10279
  toString: () => error.stack || error.toString()
10176
10280
  };
10281
+ if ('cause' in error) {
10282
+ errorObj.cause = errorToPOJO(error.cause);
10283
+ }
10284
+ return errorObj;
10177
10285
  }
10178
10286
  errors.errorToPOJO = errorToPOJO;
10179
10287
 
@@ -10193,10 +10301,10 @@ Object.defineProperty(transport, "__esModule", { value: true });
10193
10301
  var Transport_1 = transport.Transport = void 0;
10194
10302
  const events_1$5 = require$$0;
10195
10303
  const wire_1 = wire;
10196
- const transport_errors_1$2 = transportErrors;
10304
+ const transport_errors_1$6 = transportErrors;
10197
10305
  const eventAggregator_1 = eventAggregator;
10198
10306
  const me_1$1 = me;
10199
- const errors_1$1 = errors;
10307
+ const errors_1$2 = errors;
10200
10308
  class Transport extends events_1$5.EventEmitter {
10201
10309
  constructor(WireType, environment, config) {
10202
10310
  super();
@@ -10278,7 +10386,7 @@ class Transport extends events_1$5.EventEmitter {
10278
10386
  type: 'file-token'
10279
10387
  }, true);
10280
10388
  if (requestExtAuthRet.action !== 'external-authorization-response') {
10281
- throw new transport_errors_1$2.UnexpectedActionError(requestExtAuthRet.action);
10389
+ throw new transport_errors_1$6.UnexpectedActionError(requestExtAuthRet.action);
10282
10390
  }
10283
10391
  await this.environment.writeToken(requestExtAuthRet.payload.file, requestExtAuthRet.payload.token);
10284
10392
  return this.authorize(reqAuthPayload);
@@ -10286,10 +10394,10 @@ class Transport extends events_1$5.EventEmitter {
10286
10394
  async authorize(reqAuthPayload) {
10287
10395
  const requestAuthRet = await this.sendAction('request-authorization', reqAuthPayload, true);
10288
10396
  if (requestAuthRet.action !== 'authorization-response') {
10289
- throw new transport_errors_1$2.UnexpectedActionError(requestAuthRet.action);
10397
+ throw new transport_errors_1$6.UnexpectedActionError(requestAuthRet.action);
10290
10398
  }
10291
10399
  else if (requestAuthRet.payload.success !== true) {
10292
- throw new transport_errors_1$2.RuntimeError(requestAuthRet.payload);
10400
+ throw new transport_errors_1$6.RuntimeError(requestAuthRet.payload);
10293
10401
  }
10294
10402
  }
10295
10403
  sendAction(action, payload = {}, uncorrelated = false
@@ -10298,7 +10406,7 @@ class Transport extends events_1$5.EventEmitter {
10298
10406
  // eslint-disable-next-line @typescript-eslint/no-empty-function
10299
10407
  let cancel = () => { };
10300
10408
  // We want the callsite from the caller of this function, not from here.
10301
- const callSites = transport_errors_1$2.RuntimeError.getCallSite(1);
10409
+ const callSites = transport_errors_1$6.RuntimeError.getCallSite(1);
10302
10410
  const messageId = this.environment.getNextMessageId();
10303
10411
  const prom = new Promise((resolve, reject) => {
10304
10412
  cancel = reject;
@@ -10319,7 +10427,7 @@ class Transport extends events_1$5.EventEmitter {
10319
10427
  reject(payloadOrMessage);
10320
10428
  }
10321
10429
  else {
10322
- reject(new transport_errors_1$2.RuntimeError(payloadOrMessage, callSites));
10430
+ reject(new transport_errors_1$6.RuntimeError(payloadOrMessage, callSites));
10323
10431
  }
10324
10432
  }
10325
10433
  ferryAction(origData) {
@@ -10346,7 +10454,7 @@ class Transport extends events_1$5.EventEmitter {
10346
10454
  else if (this.wireListeners.has(id)) {
10347
10455
  handleNack({
10348
10456
  reason: 'Duplicate handler id',
10349
- error: (0, errors_1$1.errorToPOJO)(new transport_errors_1$2.DuplicateCorrelationError(String(id)))
10457
+ error: (0, errors_1$2.errorToPOJO)(new transport_errors_1$6.DuplicateCorrelationError(String(id)))
10350
10458
  });
10351
10459
  }
10352
10460
  else {
@@ -10378,7 +10486,7 @@ class Transport extends events_1$5.EventEmitter {
10378
10486
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10379
10487
  const { resolve, handleNack } = this.wireListeners.get(id);
10380
10488
  if (data.action !== 'ack') {
10381
- handleNack({ reason: 'Did not receive ack action', error: (0, errors_1$1.errorToPOJO)(new transport_errors_1$2.NoAckError(data.action)) });
10489
+ handleNack({ reason: 'Did not receive ack action', error: (0, errors_1$2.errorToPOJO)(new transport_errors_1$6.NoAckError(data.action)) });
10382
10490
  }
10383
10491
  else if (!('payload' in data)) {
10384
10492
  // I'm not sure when this code would actually run, but passing in something that doeesn't have a reason to the runtimeerror constructor will not end well.
@@ -10388,7 +10496,10 @@ class Transport extends events_1$5.EventEmitter {
10388
10496
  }
10389
10497
  else {
10390
10498
  console.warn('Received invalid response from core', data);
10391
- handleNack({ reason: 'invalid response shape' });
10499
+ handleNack({
10500
+ reason: 'invalid response shape',
10501
+ error: (0, errors_1$2.errorToPOJO)(new Error('Invalid response shape'))
10502
+ });
10392
10503
  }
10393
10504
  }
10394
10505
  else if (!data.payload.success) {
@@ -10409,7 +10520,7 @@ var websocket = {};
10409
10520
 
10410
10521
  Object.defineProperty(websocket, "__esModule", { value: true });
10411
10522
  const events_1$4 = require$$0;
10412
- const transport_errors_1$1 = transportErrors;
10523
+ const transport_errors_1$5 = transportErrors;
10413
10524
  const messageReceiver_1 = bridge.messageReceiver;
10414
10525
  /* `READY_STATE` is an instance var set by `constructor` to reference the `WebTransportSocket.READY_STATE` enum.
10415
10526
  * This is syntactic sugar that makes the enum accessible through the `wire` property of the various `fin` singletons.
@@ -10443,14 +10554,14 @@ class WebSocketTransport extends events_1$4.EventEmitter {
10443
10554
  });
10444
10555
  };
10445
10556
  this.connectSync = () => {
10446
- throw new transport_errors_1$1.NotImplementedError('Not Implemented');
10557
+ throw new transport_errors_1$5.NotImplementedError('Not Implemented');
10447
10558
  };
10448
10559
  this.onmessage = onmessage;
10449
10560
  }
10450
10561
  send(data, flags) {
10451
10562
  return new Promise((resolve, reject) => {
10452
10563
  if (!(0, messageReceiver_1.isOpen)(this.wire)) {
10453
- reject(new transport_errors_1$1.DisconnectedError(READY_STATE[this.wire.readyState]));
10564
+ reject(new transport_errors_1$5.DisconnectedError(READY_STATE[this.wire.readyState]));
10454
10565
  }
10455
10566
  else {
10456
10567
  // @ts-expect-error
@@ -10483,7 +10594,7 @@ var system = {};
10483
10594
  Object.defineProperty(system, "__esModule", { value: true });
10484
10595
  system.System = void 0;
10485
10596
  const base_1$d = base;
10486
- const transport_errors_1 = transportErrors;
10597
+ const transport_errors_1$4 = transportErrors;
10487
10598
  const window_1 = requireWindow();
10488
10599
  const events_1$3 = require$$0;
10489
10600
  /**
@@ -11573,9 +11684,9 @@ class System extends base_1$d.EmitterBase {
11573
11684
  });
11574
11685
  // node.js environment not supported
11575
11686
  if (this.wire.environment.type !== 'openfin') {
11576
- throw new transport_errors_1.NotSupportedError('downloadAsset only supported in an OpenFin Render process');
11687
+ throw new transport_errors_1$4.NotSupportedError('downloadAsset only supported in an OpenFin Render process');
11577
11688
  }
11578
- const callSite = transport_errors_1.RuntimeError.getCallSite();
11689
+ const callSite = transport_errors_1$4.RuntimeError.getCallSite();
11579
11690
  const downloadId = this.wire.environment.getNextMessageId().toString();
11580
11691
  const dlProgressKey = `asset-download-progress-${downloadId}`;
11581
11692
  const dlErrorKey = `asset-download-error-${downloadId}`;
@@ -11595,7 +11706,7 @@ class System extends base_1$d.EmitterBase {
11595
11706
  const dlError = (payload) => {
11596
11707
  cleanListeners();
11597
11708
  const { reason, err: error } = payload;
11598
- reject(new transport_errors_1.RuntimeError({ reason, error }, callSite));
11709
+ reject(new transport_errors_1$4.RuntimeError({ reason, error }, callSite));
11599
11710
  };
11600
11711
  const dlComplete = () => {
11601
11712
  cleanListeners();
@@ -11646,11 +11757,11 @@ class System extends base_1$d.EmitterBase {
11646
11757
  * ```
11647
11758
  */
11648
11759
  downloadRuntime(options, progressListener) {
11649
- const callsites = transport_errors_1.RuntimeError.getCallSite();
11760
+ const callsites = transport_errors_1$4.RuntimeError.getCallSite();
11650
11761
  return new Promise((resolve, reject) => {
11651
11762
  // node.js environment not supported
11652
11763
  if (this.wire.environment.type !== 'openfin') {
11653
- reject(new transport_errors_1.NotSupportedError('downloadRuntime only supported in an OpenFin Render process'));
11764
+ reject(new transport_errors_1$4.NotSupportedError('downloadRuntime only supported in an OpenFin Render process'));
11654
11765
  return;
11655
11766
  }
11656
11767
  const downloadId = this.wire.environment.getNextMessageId().toString();
@@ -11672,7 +11783,7 @@ class System extends base_1$d.EmitterBase {
11672
11783
  const dlError = (payload) => {
11673
11784
  cleanListeners();
11674
11785
  const { reason, err: error } = payload;
11675
- reject(new transport_errors_1.RuntimeError({ reason, error }, callsites));
11786
+ reject(new transport_errors_1$4.RuntimeError({ reason, error }, callsites));
11676
11787
  };
11677
11788
  const dlComplete = () => {
11678
11789
  cleanListeners();
@@ -12407,6 +12518,7 @@ var channel = {};
12407
12518
 
12408
12519
  Object.defineProperty(channel, "__esModule", { value: true });
12409
12520
  channel.ChannelBase = channel.ProtectedItems = void 0;
12521
+ const transport_errors_1$3 = transportErrors;
12410
12522
  const resultOrPayload = (func) => async (topic, payload, senderIdentity) => {
12411
12523
  const res = await func(topic, payload, senderIdentity);
12412
12524
  return res === undefined ? payload : res;
@@ -12439,6 +12551,7 @@ class ChannelBase {
12439
12551
  return this.postAction ? await this.postAction(topic, actionProcessed, senderIdentity) : actionProcessed;
12440
12552
  }
12441
12553
  catch (e) {
12554
+ transport_errors_1$3.RuntimeError.trimEndCallSites(e, /Channel.*processAction/);
12442
12555
  if (this.errorMiddleware) {
12443
12556
  return this.errorMiddleware(topic, e, senderIdentity);
12444
12557
  }
@@ -12740,6 +12853,25 @@ class ChannelBase {
12740
12853
  }
12741
12854
  channel.ChannelBase = ChannelBase;
12742
12855
 
12856
+ var channelError = {};
12857
+
12858
+ Object.defineProperty(channelError, "__esModule", { value: true });
12859
+ channelError.ChannelError = void 0;
12860
+ const transport_errors_1$2 = transportErrors;
12861
+ class ChannelError extends Error {
12862
+ constructor(originalError, action, dispatchPayload, callsites) {
12863
+ super(originalError.message);
12864
+ this.action = action;
12865
+ this.dispatchPayload = dispatchPayload;
12866
+ this.name = this.constructor.name;
12867
+ if ('cause' in originalError && originalError.cause instanceof Error) {
12868
+ this.cause = originalError.cause;
12869
+ }
12870
+ this.stack = transport_errors_1$2.RuntimeError.prepareStackTrace(this, callsites);
12871
+ }
12872
+ }
12873
+ channelError.ChannelError = ChannelError;
12874
+
12743
12875
  var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12744
12876
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12745
12877
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -12754,7 +12886,9 @@ var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateF
12754
12886
  var _ChannelClient_protectedObj, _ChannelClient_strategy, _ChannelClient_close;
12755
12887
  Object.defineProperty(client, "__esModule", { value: true });
12756
12888
  client.ChannelClient = void 0;
12889
+ const transport_errors_1$1 = transportErrors;
12757
12890
  const channel_1$1 = channel;
12891
+ const channel_error_1$1 = channelError;
12758
12892
  const channelClientsByEndpointId = new Map();
12759
12893
  /**
12760
12894
  * Instance created to enable use of a channel as a client. Allows for communication with the
@@ -12856,7 +12990,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
12856
12990
  */
12857
12991
  async dispatch(action, payload) {
12858
12992
  if (__classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
12859
- return __classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload);
12993
+ const callSites = transport_errors_1$1.RuntimeError.getCallSite();
12994
+ return __classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
12995
+ throw new channel_error_1$1.ChannelError(e, action, payload, callSites);
12996
+ });
12860
12997
  }
12861
12998
  throw new Error('The client you are trying to dispatch from is disconnected from the target provider.');
12862
12999
  }
@@ -12971,7 +13108,7 @@ class ClassicStrategy {
12971
13108
  _ClassicStrategy_endpointIdentityMap.set(this, new Map());
12972
13109
  // Store a set of cancellable promises to be able to reject them when client
12973
13110
  // connection problems occur
12974
- _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map);
13111
+ _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map());
12975
13112
  this.send = async (endpointId, action, payload) => {
12976
13113
  const to = __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
12977
13114
  if (!to) {
@@ -12985,17 +13122,21 @@ class ClassicStrategy {
12985
13122
  }
12986
13123
  delete cleanId.isLocalEndpointId;
12987
13124
  // grab the promise before awaiting it to save in our pending messages map
12988
- const p = __classPrivateFieldGet$9(this, _ClassicStrategy_wire, "f")
12989
- .sendAction('send-channel-message', {
13125
+ const p = __classPrivateFieldGet$9(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
12990
13126
  ...cleanId,
12991
13127
  providerIdentity: this.providerIdentity,
12992
13128
  action,
12993
13129
  payload
12994
13130
  });
12995
13131
  __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
12996
- const raw = await p.catch((error) => {
13132
+ const raw = await p
13133
+ .catch((error) => {
13134
+ if ('cause' in error) {
13135
+ throw error;
13136
+ }
12997
13137
  throw new Error(error.message);
12998
- }).finally(() => {
13138
+ })
13139
+ .finally(() => {
12999
13140
  // clean up the pending promise
13000
13141
  __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
13001
13142
  });
@@ -13059,7 +13200,7 @@ var _RTCEndpoint_processAction, _RTCEndpoint_disconnectListener;
13059
13200
  Object.defineProperty(endpoint, "__esModule", { value: true });
13060
13201
  endpoint.RTCEndpoint = void 0;
13061
13202
  /* eslint-disable @typescript-eslint/no-unused-vars */
13062
- const errors_1 = errors;
13203
+ const errors_1$1 = errors;
13063
13204
  /*
13064
13205
  This handles sending RTC messages between RTC connections over the request and response data channels.
13065
13206
  */
@@ -13148,7 +13289,7 @@ class RTCEndpoint {
13148
13289
  if (this.rtc.channels.response.readyState === 'open') {
13149
13290
  this.rtc.channels.response.send(JSON.stringify({
13150
13291
  messageId,
13151
- error: (0, errors_1.errorToPOJO)(error),
13292
+ error: (0, errors_1$1.errorToPOJO)(error),
13152
13293
  success: false
13153
13294
  }));
13154
13295
  }
@@ -13464,8 +13605,10 @@ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateF
13464
13605
  var _ChannelProvider_connections, _ChannelProvider_protectedObj, _ChannelProvider_strategy, _ChannelProvider_removeEndpoint, _ChannelProvider_close;
13465
13606
  Object.defineProperty(provider, "__esModule", { value: true });
13466
13607
  provider.ChannelProvider = void 0;
13467
- const channel_1 = channel;
13608
+ const transport_errors_1 = transportErrors;
13468
13609
  const runtimeVersioning_1 = runtimeVersioning;
13610
+ const channel_1 = channel;
13611
+ const channel_error_1 = channelError;
13469
13612
  /**
13470
13613
  * Instance created to enable use of a channel as a provider. Allows for communication with the {@link ChannelClient ChannelClients} by invoking an action on
13471
13614
  * a single client via {@link ChannelProvider#dispatch dispatch} or all clients via {@link ChannelProvider#publish publish}
@@ -13582,7 +13725,10 @@ class ChannelProvider extends channel_1.ChannelBase {
13582
13725
  dispatch(to, action, payload) {
13583
13726
  const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
13584
13727
  if (endpointId && __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
13585
- return __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload);
13728
+ const callSites = transport_errors_1.RuntimeError.getCallSite();
13729
+ return __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
13730
+ throw new channel_error_1.ChannelError(e, action, payload, callSites);
13731
+ });
13586
13732
  }
13587
13733
  return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
13588
13734
  }
@@ -13795,6 +13941,7 @@ Object.defineProperty(messageReceiver, "__esModule", { value: true });
13795
13941
  messageReceiver.MessageReceiver = void 0;
13796
13942
  const client_1$1 = client;
13797
13943
  const base_1$b = base;
13944
+ const errors_1 = errors;
13798
13945
  /*
13799
13946
  This is a singleton (per fin object) tasked with routing messages coming off the ipc to the correct endpoint.
13800
13947
  It needs to be a singleton because there can only be one per wire. It tracks both clients and providers' processAction passed in via the strategy.
@@ -13823,6 +13970,7 @@ class MessageReceiver extends base_1$b.Base {
13823
13970
  if (!handler) {
13824
13971
  ackToSender.payload.success = false;
13825
13972
  ackToSender.payload.reason = `Client connection with identity uuid: ${this.wire.me.uuid} / name: ${this.wire.me.name} / endpointId: ${key} no longer connected.`;
13973
+ ackToSender.payload.error = (0, errors_1.errorToPOJO)(new Error(ackToSender.payload.reason));
13826
13974
  return this.wire.sendRaw(ackToSender);
13827
13975
  }
13828
13976
  try {
@@ -13834,6 +13982,7 @@ class MessageReceiver extends base_1$b.Base {
13834
13982
  catch (e) {
13835
13983
  ackToSender.payload.success = false;
13836
13984
  ackToSender.payload.reason = e.message;
13985
+ ackToSender.payload.error = (0, errors_1.errorToPOJO)(e);
13837
13986
  return this.wire.sendRaw(ackToSender);
13838
13987
  }
13839
13988
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/remote-adapter",
3
- "version": "40.82.3",
3
+ "version": "40.82.4",
4
4
  "description": "Establish intermachine runtime connections using webRTC.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,
@@ -19,6 +19,6 @@
19
19
  "author": "OpenFin",
20
20
  "dependencies": {
21
21
  "lodash": "^4.17.21",
22
- "@openfin/core": "40.82.3"
22
+ "@openfin/core": "40.82.4"
23
23
  }
24
24
  }