Skip to content
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

[Bug]: Custom Error objects seems to break error formatter #222

Open
Sammaye opened this issue Nov 2, 2022 · 0 comments
Open

[Bug]: Custom Error objects seems to break error formatter #222

Sammaye opened this issue Nov 2, 2022 · 0 comments

Comments

@Sammaye
Copy link

Sammaye commented Nov 2, 2022

The problem

I wrote this SO question: https://stackoverflow.com/questions/74294474/winston-format-errors-breaks-aws-error-logging

The more I debugged it the more it seemed to be the fact that AWS SDK responds with its own Error object, so I did a small hack like so:

            if (err instanceof Error) {
                // 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;
            }

Before I call Winston, and even though, yes it will just take standard errors and copy them it will also take custom ones and copy them and everything works great.

This seems very buggy to me since errors are literally getting lost and now I realise why my app is constantly getting bugs I cannot see errors for.

What version of Logform presents the issue?

v2.2.0

What version of Node are you using?

v16.14.2

If this worked in a previous version of Logform, which was it?

No response

Minimum Working Example

In order to replicate this I made a call to a S3 file that did not exist, but I am sure it is to do with any custom Error implementation.

Additional information

No response

🔎 Search Terms

winston breaks aws errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant