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

domain: should variable domain in EventEmitter be private #34720

Open
cuijinyu opened this issue Aug 11, 2020 · 2 comments
Open

domain: should variable domain in EventEmitter be private #34720

cuijinyu opened this issue Aug 11, 2020 · 2 comments
Labels
domain Issues and PRs related to the domain subsystem.

Comments

@cuijinyu
Copy link

  • version: Node v10.5:
  • platform: Darwin Kernel Version 19.3.0:
  • core module name: domain:

What steps will reproduce the bug?

The domain module overwrites the EventEmitter and mounts the domain on the EventEmitter. This causes a problem. If a third-party library mounts a variable named domain on the EventEmitter and introduces the domain module at the same time, it will cause an error.
We use the request library, which mounts the request body on EventEmitter. There is a domain field in our request body, and there is an error of domain.enter is not a function (domain is overwritten as a string at this time)

How often does it reproduce? Is there a required condition?

  1. Import domain
  2. Inherit the EventEmitter class
  3. There is a variable named domain

What is the expected behavior?

domain should be private

What do you see instead?

image

Additional information

I see that the domain module no longer accepts PRs, can I submit a PR for this issue

@cuijinyu
Copy link
Author

cuijinyu commented Aug 11, 2020

require('domain')
const EventEmitter = require('events').EventEmitter;

class Test extends EventEmitter {
    constructor(props) {
        super(props)
        this.domain = '123'
    }
}

const demo = new Test()

demo.emit('haha', 'haha')```

@cuijinyu
Copy link
Author

Some third-party libraries will mount to EventEmitter. This problem will occur when a domain appears. The above is a demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain Issues and PRs related to the domain subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants