@trackunit/react-core-contexts 2.7.37 → 2.7.39

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.
package/index.cjs.js CHANGED
@@ -12,6 +12,7 @@ var utilities = require('@apollo/client/utilities');
12
12
  var graphql = require('graphql');
13
13
  var graphqlSse = require('graphql-sse');
14
14
  var error = require('@apollo/client/link/error');
15
+ var sharedUtils = require('@trackunit/shared-utils');
15
16
  var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
16
17
  var reactComponents = require('@trackunit/react-components');
17
18
  var irisAppRuntimeCoreApi = require('@trackunit/iris-app-runtime-core-api');
@@ -61,8 +62,13 @@ const getMissingScopeMessages = (errors) => errors.map(error => error.message).f
61
62
  const createErrorLink = ({ errorHandler, getToken, showErrorToast, }) => {
62
63
  return error.onError(({ graphQLErrors, networkError, operation, response, forward }) => {
63
64
  if (networkError) {
64
- // We skip the error logging if the error is an AbortError
65
- if (networkError.name === "AbortError") {
65
+ // We skip the error logging if the error is an AbortError, or if the request was cut short
66
+ // by a full page navigation we triggered ourselves — the browser reports the requests it
67
+ // cancels while tearing down the document as a plain TypeError, not an AbortError.
68
+ // A ServerError can carry graphQLErrors on the same payload; those remain application
69
+ // errors and must still be reported even while navigating away.
70
+ if (networkError.name === "AbortError" ||
71
+ (sharedUtils.isNavigatingAway() && (graphQLErrors === undefined || graphQLErrors.length === 0))) {
66
72
  return;
67
73
  }
68
74
  // eslint-disable-next-line no-console
@@ -220,7 +226,12 @@ const createSubscriptionErrorLink = ({ errorHandler, getToken, showErrorToast, g
220
226
  // unmount or navigation) — graphql-sse calls control.abort() which
221
227
  // fires this error asynchronously. Swallow it to prevent an
222
228
  // unhandled rejection, mirroring the guard in createErrorLink.
223
- if (err instanceof Error && err.name === "AbortError") {
229
+ // A full page navigation we triggered ourselves tears the connection
230
+ // down too, but surfaces as a plain TypeError instead.
231
+ // Complete the wrapper: the inner connection is already dead, and
232
+ // leaving this Observable open would mute reconnects if navigation fails.
233
+ if ((err instanceof Error && err.name === "AbortError") || sharedUtils.isNavigatingAway()) {
234
+ observer.complete();
224
235
  return;
225
236
  }
226
237
  // eslint-disable-next-line no-console
package/index.esm.js CHANGED
@@ -10,6 +10,7 @@ import { getMainDefinition, Observable as Observable$1 } from '@apollo/client/ut
10
10
  import { print } from 'graphql';
11
11
  import { createClient } from 'graphql-sse';
12
12
  import { onError } from '@apollo/client/link/error';
13
+ import { isNavigatingAway } from '@trackunit/shared-utils';
13
14
  import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
14
15
  import { Spinner } from '@trackunit/react-components';
15
16
  import { Channels, SortOrder, AssetSortByProperty } from '@trackunit/iris-app-runtime-core-api';
@@ -59,8 +60,13 @@ const getMissingScopeMessages = (errors) => errors.map(error => error.message).f
59
60
  const createErrorLink = ({ errorHandler, getToken, showErrorToast, }) => {
60
61
  return onError(({ graphQLErrors, networkError, operation, response, forward }) => {
61
62
  if (networkError) {
62
- // We skip the error logging if the error is an AbortError
63
- if (networkError.name === "AbortError") {
63
+ // We skip the error logging if the error is an AbortError, or if the request was cut short
64
+ // by a full page navigation we triggered ourselves — the browser reports the requests it
65
+ // cancels while tearing down the document as a plain TypeError, not an AbortError.
66
+ // A ServerError can carry graphQLErrors on the same payload; those remain application
67
+ // errors and must still be reported even while navigating away.
68
+ if (networkError.name === "AbortError" ||
69
+ (isNavigatingAway() && (graphQLErrors === undefined || graphQLErrors.length === 0))) {
64
70
  return;
65
71
  }
66
72
  // eslint-disable-next-line no-console
@@ -218,7 +224,12 @@ const createSubscriptionErrorLink = ({ errorHandler, getToken, showErrorToast, g
218
224
  // unmount or navigation) — graphql-sse calls control.abort() which
219
225
  // fires this error asynchronously. Swallow it to prevent an
220
226
  // unhandled rejection, mirroring the guard in createErrorLink.
221
- if (err instanceof Error && err.name === "AbortError") {
227
+ // A full page navigation we triggered ourselves tears the connection
228
+ // down too, but surfaces as a plain TypeError instead.
229
+ // Complete the wrapper: the inner connection is already dead, and
230
+ // leaving this Observable open would mute reconnects if navigation fails.
231
+ if ((err instanceof Error && err.name === "AbortError") || isNavigatingAway()) {
232
+ observer.complete();
222
233
  return;
223
234
  }
224
235
  // eslint-disable-next-line no-console
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/core-contexts/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "2.7.37",
3
+ "version": "2.7.39",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,13 +8,14 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@trackunit/iris-app-api": "2.4.36",
11
- "@trackunit/iris-app-runtime-core-api": "1.17.47",
12
- "@trackunit/react-core-hooks": "1.21.47",
13
- "@trackunit/i18n-library-translation": "2.4.47",
14
- "@trackunit/react-components": "2.13.6",
15
- "@trackunit/iris-app-runtime-core": "1.18.47",
11
+ "@trackunit/iris-app-runtime-core-api": "1.17.49",
12
+ "@trackunit/react-core-hooks": "1.21.49",
13
+ "@trackunit/i18n-library-translation": "2.4.49",
14
+ "@trackunit/react-components": "2.13.8",
15
+ "@trackunit/iris-app-runtime-core": "1.18.49",
16
16
  "graphql-sse": "^2.6.0",
17
- "@trackunit/react-core-contexts-api": "1.18.47"
17
+ "@trackunit/react-core-contexts-api": "1.18.49",
18
+ "@trackunit/shared-utils": "1.16.40"
18
19
  },
19
20
  "peerDependencies": {
20
21
  "@apollo/client": "^3.13.8",