-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All exceptions are logged into the console #13462
Comments
I'm not sure what your exact issue is and how it is Sentry related. You receive logs for unhandled errors? Also, you can simplify your init like this: const client = Sentry.init({
dsn,
tracesSampleRate: 1.0,
integrations: Sentry.getDefaultIntegrations({}).filter((integration) => integration.name !== 'Http'),
release: version
}); |
Hey @chargome! Now to clarify my problem: I have a custom exception/rejection handler which prevents crashes and logs the errors to the console. But as soon as I initialize sentry, the complete exceptions are also being logged (Which doesn't happen if I don't initialize Sentry). So it has to be a problem with this wrapper I suppose. I just want my log to look clean but those big exceptions just make it look bad, especially as they're logged in a prettier format before the unwanted Sentry log. |
@RappyTV can you paste a snippet of your custom exception handler? |
@chargome import Logger from "./Logger";
import { captureException } from "@sentry/bun";
import { sentry } from "../../config.json";
export default function handleErrors() {
Logger.debug(`Exception handler initialized.`);
process.on('unhandledRejection', (reason) => {
Logger.error(`Unhandled rejection: "${reason}"`);
if(sentry.enabled) captureException(reason);
});
process.on('uncaughtException', (error) => {
Logger.error(`Unhandled exception: "${error}"`);
if(sentry.enabled) captureException(error);
});
} (Also the issue still occurs even if I comment-out the |
@RappyTV |
The import chalk from "chalk";
import { logLevel } from "../../config.json";
enum LogLevel {
Error,
Warn,
Info,
Debug
}
export default class Logger {
public static debug(text: any, ...options: any[]) {
if(LogLevel.Debug > Logger.getLoglevel()) return;
console.log(chalk.blueBright(`[DEBUG]`), text, options.join(' '));
}
public static info(text: any, ...options: any[]) {
if(LogLevel.Info > Logger.getLoglevel()) return;
console.log(chalk.blue(`[INFO]`), text, options.join(' '));
}
public static warn(text: any, ...options: any[]) {
if(LogLevel.Warn > Logger.getLoglevel()) return;
console.log(chalk.yellow(`[WARN]`), text, options.join(' '));
}
public static error(text: any, ...options: any[]) {
if(LogLevel.Error > Logger.getLoglevel()) return;
console.log(chalk.red(`[ERROR]`), text, options.join(' '));
}
public static getLoglevel(): LogLevel {
return LogLevel[logLevel as keyof typeof LogLevel] || LogLevel.Info;
}
} so that's probably not it. import { initializeSentry } from "./util/Sentry";
import handleErrors from "./util/ErrorHandler";
handleErrors();
if(config.sentry.enabled) initializeSentry(config.sentry.dsn); |
Seems that the issue is somewhere else still. Would you mind to create a small reproducible repo / stackblitz, this would help to fix your issue more efficiently. |
As it's a private repository and I don't really plan on making it public I would provide you a zip download link. The link expires in 3 days https://media.rappytv.com/u/2VVgNF.zip |
Thanks for the submission. I'll take a look at it too. |
Thank you guys! |
@RappyTV need some instructions on how to run your app :) please provide a valid |
@andreiborza |
Hi, I think I understand what is happening. Our
Thereby it is logging the rejection and this is what may cause the error to appear in your logs. You can disable this by doing: Sentry.init({
integrations: [Sentry.onUnhandledRejectionIntegration({ mode: 'none' })]
}) However, when your application throws unhandled promise rejections, they will not be reported that way. You can fix this by manually registering a |
Hey thanks a lot, that did in fact work. Just a little info because you said that I need to use my own handler for unhandled rejections (Which also was my intention in the first place): The exceptions/rejections are being reported to my sentry instance anyways even without my custom handler. You might wanna look into that if you didn't expect that behavior. But I don't have any problems anymore so feel free to close the issue. |
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/bun
SDK Version
8.26.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Steps to Reproduce
Expected Result
I receive my own exception handler log:
Actual Result
I receive my own log + a log which I don't want and seemingly can't disable:
The text was updated successfully, but these errors were encountered: