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

TypeError: Cannot set property ...... of Error which has only a getter #234

Open
koloboid opened this issue May 23, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@koloboid
Copy link

Hello! I've got an error "TypeError: Cannot set property message of Error which has only a getter"

Complete stacktrace:

    at node_modules/tslog/dist/cjs/BaseLogger.js:179:45
    at Array.reduce (<anonymous>)
    at Logger._recursiveCloneAndMaskValuesOfKeys (node_modules/tslog/dist/cjs/BaseLogger.js:178:70)
    at node_modules/tslog/dist/cjs/BaseLogger.js:157:25
    at Array.map (<anonymous>)
    at Logger._mask (node_modules/tslog/dist/cjs/BaseLogger.js:156:22)
    at Logger.log (node_modules/tslog/dist/cjs/BaseLogger.js:99:24)
    at Logger.error (node_modules/tslog/dist/cjs/index.js:29:22)

The code is simple:

import { messaging } from 'firebase-admin';

try {
    await messaging().send({ token }, true);
} catch (err) {
    this.log.error(err);
}

so, what we have - firebase-admin generates a special Error object with a "message" property which has only a getter, while tslog tries to modify this object at

o[prop] = keys.includes(this.settings?.maskValuesOfKeysCaseInsensitive !== true ? prop : prop.toLowerCase())

It's really unexpected when the logging library mutates input data, so it looks like a bug. @terehov please, let me know if I can help you debug this case

@koloboid koloboid added the bug Something isn't working label May 23, 2023
@koloboid
Copy link
Author

I think it's related to #227

@koloboid koloboid changed the title Bug: [BUG] TypeError: Cannot set property ...... of Error which has only a getter May 23, 2023
@terehov
Copy link
Contributor

terehov commented Aug 7, 2023

#227 should be solved now

@koloboid
Copy link
Author

koloboid commented Aug 8, 2023

#227 should be solved now

ok, thanks! I'll check it out, and let you know. I had issues with logging Firebase and Typeorm errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants