tslog icon indicating copy to clipboard operation
tslog copied to clipboard

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

Open koloboid opened this issue 2 years ago • 3 comments

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 https://github.com/fullstack-build/tslog/blob/0e751a5636abcbdceadf38cb1d180613f41380b5/src/BaseLogger.ts#L224

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 avatar May 23 '23 12:05 koloboid

I think it's related to #227

koloboid avatar May 23 '23 12:05 koloboid

#227 should be solved now

terehov avatar Aug 07 '23 21:08 terehov

#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

koloboid avatar Aug 08 '23 07:08 koloboid