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: Cannot set property native of #<Object> which has only a getter #190

Closed
quinnturner opened this issue Dec 7, 2022 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@quinnturner
Copy link
Contributor

quinnturner commented Dec 7, 2022

Describe the bug

 TypeError  Cannot set property native of #<PG> which has only a getter
error stack:
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:162
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:156
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:156
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:156
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:156
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:164
  • BaseLogger.js?__quibble=3	Logger._recursiveCloneAndMaskValuesOfKeys
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:160
  • BaseLogger.js?__quibble=3	
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:141
  • BaseLogger.js?__quibble=3	Logger._mask
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:140
  • BaseLogger.js?__quibble=3	Logger.log
	/__w/project/project/node_modules/tslog/dist/esm/BaseLogger.js?__quibble=3:80
  • index.js?__quibble=3	Logger.error
	/__w/project/project/node_modules/tslog/dist/esm/index.js?__quibble=3:26
  • api.js?__quibble=3	process.<anonymous>
	/built/src/api.js?__quibble=3:36
  • events	process.emit
	events:525

To Reproduce

Working on a reproduction. I assume that it has to do with masking a value that only has a getter?

Expected behavior

Not sure what to do here, but erroring out is not desirable.

Node.js Version
e.g. 18

@quinnturner quinnturner added the bug Something isn't working label Dec 7, 2022
@twinkle77
Copy link

same

@terehov
Copy link
Contributor

terehov commented Dec 12, 2022

I’d be happy to fix this, but some reproduction code would be very helpful.

@quinnturner
Copy link
Contributor Author

It was in the middle of a complex series of asynchronous tests, so I am not sure I am able to reproduce at this time.

My assumption is that the mask is attempting to override a value that doesn't have a setter.

@quinnturner
Copy link
Contributor Author

#192 is a reproduction of the issue.

@terehov
Copy link
Contributor

terehov commented Dec 18, 2022

Thank you guys and especially @quinnturner for your test case. It helped a lot.
So the problem was the "proper" cloning, which also copied the missing setters, which is obviously not necessary for a logger. The only use case is not to manipulate the original object.

So basically I just removed one line:

Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop)!);

And here is the explanation, why setters are visible for plain object but not class instances:
nodejs/node#30183

V4.4.5 is coming now.

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

3 participants