-
Notifications
You must be signed in to change notification settings - Fork 31
chore(lib): don't require domain by default #101
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,17 @@ | |
|
||
// external modules | ||
var assert = require('assert-plus'); | ||
var EventEmitter = require('events'); | ||
var _ = require('lodash'); | ||
var nerror = require('@netflix/nerror'); | ||
var domain = require('domain'); | ||
var MultiError = nerror.MultiError; | ||
var VError = nerror.VError; | ||
var safeJsonStringify; | ||
|
||
// We load the domain module lazily to avoid performance regression on Node.js | ||
// v12. | ||
var domain; | ||
|
||
// try to require optional dependency | ||
try { | ||
// eslint-disable-next-line global-require | ||
|
@@ -157,8 +161,17 @@ function _getSerializedContext(err) { | |
_.omit(err, self._knownFields) : | ||
{}; | ||
|
||
if (topLevelFields.domain instanceof domain.Domain) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may not be necessary anymore now that Node.js sets the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we still need to support Node.js >= 10.x, and possibly older versions (like 8.x as indicated by the Travis config) though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should keep supporting all Node.js versions which are still active (8.x, 10.x, 12.x and 13.x)? If that's the case, it will take some time for us to leverage the changes introduced on v12 (out of curiosity, those changes are also part of the performance issues I found). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although 8.x goes EOL later this month, so we can drop that soon... |
||
topLevelFields = _.omit(topLevelFields, [ 'domain' ]); | ||
// We don't want to load domains just to check if topLevelFields.domain is | ||
// a Domain instance, so first we make sure domains are already loaded. | ||
if (EventEmitter.usingDomains) { | ||
if (!domain) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can load this even more lazily by loading the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could, but if we get here domains were already loaded somewhere else. Doing it here saves us a hasOwnProperty/in. |
||
// eslint-disable-next-line global-require | ||
domain = require('domain'); | ||
} | ||
|
||
if (topLevelFields.domain instanceof domain.Domain) { | ||
topLevelFields = _.omit(topLevelFields, [ 'domain' ]); | ||
} | ||
} | ||
|
||
// combine all fields into a pojo, and serialize | ||
|
Uh oh!
There was an error while loading. Please reload this page.