Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
events: make sure console functions exist#4479
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
362d8329f8eddb04a9276ff4065ee1a14e77152739File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* eslint-disable required-modules */ | ||
| // ordinarily test files must require('common') but that action causes | ||
| // the global console to be compiled, defeating the purpose of this test | ||
| 'use strict'; | ||
| const assert = require('assert'); | ||
| const EventEmitter = require('events'); | ||
| const leak_warning = /EventEmitter memory leak detected\. 2 hello listeners/; | ||
| var write_calls = 0; | ||
| process.stderr.write = function(data) { | ||
| if (write_calls === 0) | ||
| assert.ok(data.match(leak_warning)); | ||
| else if (write_calls === 1) | ||
| assert.ok(data.match(/Trace/)); | ||
| else | ||
| assert.ok(false, 'stderr.write should be called only twice'); | ||
| write_calls++; | ||
| }; | ||
| const old_default = EventEmitter.defaultMaxListeners; | ||
| EventEmitter.defaultMaxListeners = 1; | ||
| const e = new EventEmitter(); | ||
| e.on('hello', function() {}); | ||
| e.on('hello', function() {}); | ||
| // TODO validate console | ||
Member 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. Why add the comment vs. adding the validation? Author 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. As per earlier discussion (#4479 (diff)) I don't think it's actually possible to validate the console here in any significant way, but @thefourtheye requested a comment about validating it. Member 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. oh :-) lol completely missed that one | ||
| assert.equal(write_calls, 2); | ||
Contributor 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. Shouldn't we also assert if the Author 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 don't think there's any way we can do that without incidentally initializing it. Our prior logging would have failed if Contributor 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. How about checking if Author 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. Such a reference to Author 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 suppose we could inspect Author 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. Scratch that -- Contributor 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. Hmmm, my office time has started. I'll think about this when I find time today. Let's not block this PR because of this. Perhaps you might want to leave a TODO or something in the test for the timebeing. | ||
| EventEmitter.defaultMaxListeners = old_default; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why we have
assert.equal(write_calls, 2);at the end, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I felt like I should have some sort of catch-all
elsestatement here though.