From ea75675f5d5749aea1b51491587d726a6b648ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Wed, 24 Mar 2021 10:39:14 +0100 Subject: [PATCH] [v7] Remove forget async util --- .../integration-node-globalhandlers/src/exit.ts | 14 +++++++++----- packages/utils/src/async.ts | 12 ------------ packages/utils/src/index.ts | 1 - 3 files changed, 9 insertions(+), 18 deletions(-) delete mode 100644 packages/utils/src/async.ts diff --git a/packages/integration-node-globalhandlers/src/exit.ts b/packages/integration-node-globalhandlers/src/exit.ts index 132a95e1fd8b..c9abe9c1f275 100644 --- a/packages/integration-node-globalhandlers/src/exit.ts +++ b/packages/integration-node-globalhandlers/src/exit.ts @@ -1,5 +1,5 @@ import { ClientLike } from '@sentry/types'; -import { forget, logger } from '@sentry/utils'; +import { logger } from '@sentry/utils'; const DEFAULT_SHUTDOWN_TIMEOUT = 2000; @@ -12,13 +12,17 @@ export function logAndExitProcess(client: ClientLike): (error: { stack?: string console.error(error && error.stack ? error.stack : error); const timeout = client.options.shutdownTimeout ?? DEFAULT_SHUTDOWN_TIMEOUT; - forget( - client.close(timeout).then((result: boolean) => { + client + .close(timeout) + .then((result: boolean) => { if (!result) { logger.warn('We reached the timeout for emptying the request buffer, still exiting now!'); } global.process.exit(1); - }), - ); + }) + .then(null, e => { + // eslint-disable-next-line no-console + console.error(e); + }); }; } diff --git a/packages/utils/src/async.ts b/packages/utils/src/async.ts deleted file mode 100644 index cff2aab42774..000000000000 --- a/packages/utils/src/async.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Consumes the promise and logs the error when it rejects. - * @param promise A promise to forget. - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function forget(promise: PromiseLike): void { - promise.then(null, e => { - // TODO: Use a better logging mechanism - // eslint-disable-next-line no-console - console.error(e); - }); -} diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 0cfcc4cd4a3c..9f0731d0a4f2 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,4 +1,3 @@ -export * from './async'; export * from './browser'; export * from './error'; export * from './instrument';