Skip to content

Commit 0cf5fb5

Browse files
authored
ref(utils): remove forget async utility function (#4941)
remove the `forget()` function from Utils as it is a rather unnecessary abstraction around logging a rejected Promise via console.error and it bloats the bundle
1 parent 961d3af commit 0cf5fb5

File tree

5 files changed

+12
-48
lines changed

5 files changed

+12
-48
lines changed

packages/browser/src/transports/utils.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forget, getGlobalObject, isNativeFetch, logger, supportsFetch } from '@sentry/utils';
1+
import { getGlobalObject, isNativeFetch, logger, supportsFetch } from '@sentry/utils';
22

33
import { IS_DEBUG_BUILD } from '../flags';
44

@@ -98,13 +98,11 @@ export function sendReport(url: string, body: string): void {
9898

9999
if (supportsFetch()) {
100100
const fetch = getNativeFetchImplementation();
101-
return forget(
102-
fetch(url, {
103-
body,
104-
method: 'POST',
105-
credentials: 'omit',
106-
keepalive: true,
107-
}),
108-
);
101+
fetch(url, {
102+
body,
103+
method: 'POST',
104+
credentials: 'omit',
105+
keepalive: true,
106+
}).then(null, error => logger.error(error));
109107
}
110108
}

packages/node/src/integrations/utils/errorhandling.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getCurrentHub } from '@sentry/core';
2-
import { forget, logger } from '@sentry/utils';
2+
import { logger } from '@sentry/utils';
33

44
import { NodeClient } from '../../client';
55
import { IS_DEBUG_BUILD } from '../../flags';
@@ -24,12 +24,13 @@ export function logAndExitProcess(error: Error): void {
2424
const timeout =
2525
(options && options.shutdownTimeout && options.shutdownTimeout > 0 && options.shutdownTimeout) ||
2626
DEFAULT_SHUTDOWN_TIMEOUT;
27-
forget(
28-
client.close(timeout).then((result: boolean) => {
27+
client.close(timeout).then(
28+
(result: boolean) => {
2929
if (!result) {
3030
IS_DEBUG_BUILD && logger.warn('We reached the timeout for emptying the request buffer, still exiting now!');
3131
}
3232
global.process.exit(1);
33-
}),
33+
},
34+
error => logger.error(error),
3435
);
3536
}

packages/utils/src/async.ts

-12
This file was deleted.

packages/utils/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from './async';
21
export * from './browser';
32
export * from './dsn';
43
export * from './error';

packages/utils/test/async.test.ts

-22
This file was deleted.

0 commit comments

Comments
 (0)