Skip to content

aws-sdk errors not being logged #6964

@Sammaye

Description

@Sammaye

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/angular

SDK Version

7.34.0

Framework Version

4.17.6

Link to Sentry event

https://delenta.sentry.io/issues/3903038744/?project=6739047&query=is%3Aunresolved&referrer=issue-stream

SDK Setup

            global.process.on('uncaughtException', (error) => {
            });

            const sentryOptions = {
                environment: config.APP_ENV === 'DEV'
                    ? 'development'
                    : (
                        config.APP_ENV.includes('ALPHA')
                            ? 'alpha'
                            : (config.APP_ENV === 'BETA' ? 'beta' : 'production')
                    ),
                dsn: config.LOGS_SENTRY_DSN,
                // Set tracesSampleRate to 1.0 to capture 100%
                // of transactions for performance monitoring.
                // We recommend adjusting this value in production
                tracesSampleRate: 0.25,
                integrations: integrations => {
                    const newIntegrations = integrations.filter(integration =>
                        integration.name !== 'OnUncaughtException' &&
                        integration.name !== 'Http' &&
                        integration.name !== 'LocalVariables'
                    );

                    newIntegrations.push(
                        new Sentry.Integrations.OnUncaughtException({exitEvenIfOtherHandlersAreRegistered: false}),
                        new Sentry.Integrations.Http({tracing: true}),
                        new Sentry.Integrations.LocalVariables({
                            captureAllExceptions: true,
                        })
                    );

                    if (app) {
                        newIntegrations.push(
                            // enable Express.js middleware tracing
                            new Tracing.Integrations.Express({app}),
                        );
                    }

                    return newIntegrations;
                },
                beforeSend: function(event, hint) {
                    return event;
                }
            };

            Sentry.init(sentryOptions);

Steps to Reproduce

I noticed this nasty issue on my winston implementation as well.

aws-sdk errors come in as Error type but for some reason they simply do not work properly so in my old winston logger I overcame it with converting the error to a new Error when I got it.

This is a quick basic hack I did:

            if (err instanceof Error && err.requestId) {
                // This is a workaround for errors that have custom
                // properties, like AWS SDK errors, they do not seem to work
                // with Winston `winston.format.errors({stack: true})` so
                // we copy the error object to a new fresh error object which seems to work
                const errc = new Error(err.message);
                errc.stack = err.stack;
                err = errc;

                req.error(err);
            }

Expected Result

The error comes in as shown in the linked error, this was from me manually hacking around the issue

Actual Result

Error not logged at all as shown by no console.log in beforeSend

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions