Skip to content

Make error context a non-enumerable property to avoid serialization errors#75

Merged
Qard merged 4 commits into
othiym23:error-context-testsfrom
MyPureCloud:master
Aug 18, 2016
Merged

Make error context a non-enumerable property to avoid serialization errors#75
Qard merged 4 commits into
othiym23:error-context-testsfrom
MyPureCloud:master

Conversation

@msmithgu

Copy link
Copy Markdown

Error contexts can contain complex objects with circular references. By making the error context property non-enumerable, it's still accessible directly but won't be included automatically if someone tries to serialize the exception for logging.

@msmithgu

Copy link
Copy Markdown
Author

This may also address what #46 is trying to address: that is making the error context not writable.

@enicholson

Copy link
Copy Markdown

@othiym23 any comments on this one? We've found this really helpful preventing crashes in our service which frequently serializes error objects (for responses, logging, etc).

Thanks!

@enicholson

enicholson commented Aug 2, 2016

Copy link
Copy Markdown

@msmithgu there is one more place where the error@context is assigned on line 85: https://github.com/MyPureCloud/node-continuation-local-storage/blob/efcfebb0151fb92728e82b867b246f4f0af31c4b/context.js#L85

That should have the same behavior...

@Qard Qard changed the base branch from master to error-context-tests August 18, 2016 23:34
@Qard

Qard commented Aug 18, 2016

Copy link
Copy Markdown
Collaborator

Thanks! I'll add some tests for this and get it merged. 😸

@Qard Qard merged commit aee824a into othiym23:error-context-tests Aug 18, 2016
@wanglihui

Copy link
Copy Markdown

this fixed my problem! 3q

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

Successfully merging this pull request may close these issues.

4 participants