Skip to content

Commit e44882a

Browse files
authored
ref(node): Stop custom-handling normalization of Domain/DomainEmitter (#21182)
We have custom code normalizing Domain and DomainEmitter, which are node-only but deprecated and not widely used anymore. This would have affected this being serialized in a nested object, e.g. extra, where it would be something like: ```js // The rule is shape-based, not identity-based: any EventEmitter under `domain` matches. const emitter = new EventEmitter(); emitter.on('error', () => undefined); expect(normalize({ domain: emitter })).toEqual({ domain: '[Domain]' }); ``` or ```js // The Node `domain` module stamps the originating EventEmitter onto caught errors // under `domainEmitter`. The rule is unconditional on the key match — no shape check — // so even non-emitter values under `domainEmitter` get replaced. const realEmitter = new EventEmitter(); realEmitter.on('data', () => undefined); expect(normalize({ domainEmitter: realEmitter })).toEqual({ domainEmitter: '[DomainEmitter]' }); ``` (We don't really have tests for this, I added these to verify how this looks today, they are not in the PR since they would be removed again basically) With this PR, they will be normalized "normally", meaning they'd look something like this: ```diff { - "domain": "[Domain]", + "domain": { + "_events": { + "newListener": "[Function: updateExceptionCapture]", + "removeListener": "[Function: updateExceptionCapture]", + }, + "_eventsCount": 2, + "_maxListeners": undefined, + "members": [], + }, } ``` or ```diff { - "domainEmitter": "[DomainEmitter]", + "domainEmitter": { + "_events": { + "data": "[Function: <anonymous>]", + }, + "_eventsCount": 1, + "_maxListeners": undefined, + }, } ``` which is of course "worse" but IMHO this deprecated, not widely used feature does not necessarily warranty special handling in core - this code is also shipped to browsers.
1 parent ed0c4cf commit e44882a

1 file changed

Lines changed: 0 additions & 8 deletions

File tree

packages/core/src/utils/normalize.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,6 @@ function stringifyValue(
187187
value: Exclude<unknown, string | number | boolean | null>,
188188
): string {
189189
try {
190-
if (key === 'domain' && value && typeof value === 'object' && (value as { _events: unknown })._events) {
191-
return '[Domain]';
192-
}
193-
194-
if (key === 'domainEmitter') {
195-
return '[DomainEmitter]';
196-
}
197-
198190
// It's safe to use `global`, `window`, and `document` here in this manner, as we are asserting using `typeof` first
199191
// which won't throw if they are not present.
200192

0 commit comments

Comments
 (0)