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: Error thrown of setting a property name that only has a getter #96

Closed
auguwu opened this issue Mar 26, 2021 · 0 comments
Closed

Bug: Error thrown of setting a property name that only has a getter #96

auguwu opened this issue Mar 26, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@auguwu
Copy link

auguwu commented Mar 26, 2021

Describe the bug
In some applications, ts-log will report the error (this is with ts-node, same errors produces in normal JavaScript!):

 TypeError  Cannot set property name of  which has only a getter
error stack:
 LoggerWithoutCallSite.ts:463 _buildErrorObject
    node_modules\tslog\src\LoggerWithoutCallSite.ts:463:21

 LoggerWithoutCallSite.ts:424 <anonymous>
    node_modules\tslog\src\LoggerWithoutCallSite.ts:424:16

 LoggerWithoutCallSite.ts:421 _buildLogObject
    node_modules\tslog\src\LoggerWithoutCallSite.ts:421:28

 LoggerWithoutCallSite.ts:332 _handleLog
    node_modules\tslog\src\LoggerWithoutCallSite.ts:332:40

 LoggerWithoutCallSite.ts:289 fatal
    node_modules\tslog\src\LoggerWithoutCallSite.ts:289:28

 main.ts:54 <anonymous>
    main.ts:54:60node:events:327 emit
    node:events:327:20node:domain:486 EventEmitter.emit
    node:domain:486:12

 source-map-support.js:495 process.emit
    C:\Users\<name>\AppData\Roaming\npm\node_modules\ts-node\node_modules\source-map-support\source-map-support.js:495:21

To Reproduce
This happens when you do:

const { Logger } = require('tslog');
const logger = new Logger();

class CustomError extends Error {
  get name() {
    return 'CustomError';
  }
}

try {
  throw new CustomError();
} catch(ex) {
  logger.fatal(ex);
  // logger.error(ex); also causes it!
}

Expected behavior
Shouldn't override setters (it seems?) and the error should be printed.

Node.js Version
v15.0.1

OS incl. Version
Windows 10 Pro (build 2004, 10.0.19041)

@auguwu auguwu added the bug Something isn't working label Mar 26, 2021
terehov added a commit that referenced this issue Apr 14, 2021
@auguwu auguwu closed this as completed Apr 20, 2021
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

1 participant