Skip to content

Zone.js should patch EventEmitter.prototype.off #35473

@lddubeau

Description

@lddubeau

Affected Package

The issue is caused by package zone.js

Is this a regression?

Not to my knowledge.

Description

When running in Node, and with patching enabled (the default), Zone does not completely patch EventEmitter.

Zone patches EventEmitter.prototype.on just like it patches EventEmitter.prototoype.addListener because on is an alias for addListener.

However, though off is an alias for removeListener (added in Node 10.0.0), Zone patches EventEmitter.prototoype.removeListener but fails to patch EventEmitter.prototype.off.

🔬 Minimal Reproduction

Clone this repo: https://github.com/lddubeau/zone-bug1-should-patch-off

Then run:

npm install
node index.js

Expected Output

handler got prior to off

Actual Output

handler got prior to off
handler got after off

Discussion

The after off is called to remove the handler, the handler is still there. If the patch variable is set to true to execute the if branch, then we get the expected results.

🌍 Your Environment

Angular Version: I'm just using Zone.js
Zone.js version: 0.10.2
Node.js version: 12.15.0

Metadata

Metadata

Assignees

Labels

area: zonesIssues related to zone.jsfeatureLabel used to distinguish feature request from other issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions