Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const exitProcess = () => {
const sentryClient = Sentry.getCurrentHub().getClient();
// eslint-disable-next-line promise/catch-or-return, promise/always-return, promise/no-promise-in-callback, no-process-exit
if (sentryClient) sentryClient.close(2000).then(() => process.exit(1));
else process.exit(1); // eslint-disable-line no-process-exit
};
async trackError(err) {
if (!this.sentryInitialized) {
return;
}
Sentry.captureException(err);
// Returns a promise that will be resolved in 2000ms,
// which is the timeout to resolve all pending communication
// with Sentry servers.
// @see https://docs.sentry.io/learn/draining
const client = Sentry.getCurrentHub().getClient();
return await client.close(2000);
}
flush() {
// Give 2 seconds to flush Sentry data
const sentryClient = Sentry.getCurrentHub().getClient()
return sentryClient ? sentryClient.close( 2000 ) : Promise.resolve()
}
}
async function cleanup (exitCode: string) {
await Sentry.getCurrentHub().getClient()!!.close(2000)
if (global.discord) await discord.client.destroy()
console.error(exitCode)
}
}
export function drain() {
const client = Sentry.getCurrentHub().getClient();
if (client) {
return client.close(2000);
}
return Promise.resolve();
}
(params, callback) => {
spans.compile = Sentry.getCurrentHub().startSpan({
op: 'compile',
});
callback();
}
);
export function closeSentry () {
return Sentry.getCurrentHub().getClient()!!.close(2000)
}