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

Properly add/cleanup process event listeners. #2693

Merged
merged 3 commits into from
Jan 8, 2016

Conversation

haavardw
Copy link
Contributor

Add and cleanup process event listeners properly.

Fixes warnings when doing lift/lower multiple times, e.g in before() and
after() functions in a test suite.

Tests:
test/integration/lift.lower.test.js
test/unit/app.lower.test.js

@sgress454
Copy link
Member

Don't use process.once as this replaces any existing listeners.

This is news to me! .once() just means that the listener will only be fired once and then removed; it doesn't have any effect on other listeners attached to the event.

@haavardw
Copy link
Contributor Author

haavardw commented Mar 2, 2015

@sgress454 , you're right, my description was not correct. I've restored the use of .once() .on() to the original use, but kept the cleanup in app.lower(). I've added tests that demonstrates the warning that typicall arises in a test suite (test/integration/lift.lower.test.js) and a unit test that checks that we remove the eventlisteners on lower (test/unit/app.lower.test.js).

@haavardw haavardw force-pushed the master branch 2 times, most recently from 966d5cc to 8057e1a Compare March 2, 2015 20:01
@haavardw haavardw force-pushed the master branch 3 times, most recently from 91e6a08 to ae3c428 Compare March 25, 2015 14:46
@sgress454
Copy link
Member

Hm, the tests fail when I run this--it looks like it might not be lowering correctly, because I get a

error: Trying to start server on port 1337 but can't...Something else is probably running on that port!

in the app.lower tests.

@haavardw
Copy link
Contributor Author

@sgress454 It fails in travis as well but not for me locally so I'm a bit puzzelled. Any clue on what kind of environment I need to test with? (I'm running node 0.12 on linux).

Also, it looks to me like the travis run fails during lift (not lower). Could it be that a previous test doesn't lower correctly?

@washimimizuku
Copy link

This fails when Node is <0.12

haavardw added 3 commits July 19, 2015 14:58
Fixes warnings when doing lift/lower multiple times, e.g in before() and
after() functions in a test suite.

See test/integration/lift.lower.test.js
@mikermcneil
Copy link
Member

@sgress454 @washimimizuku thanks y'all

@haavardw would you mind rebasing from master and giving this another go? For a while this year, a PR was merged that added something to our npm test script that caused it to fail intermittently for reasons unrelated to the content of the PR (it was checking duplicate code). It would definitely be worth it to give it a fresh run on the latest and see where it stands.

@sgress454
Copy link
Member

Works for me now on all Node versions, and passed Travis w/ Node 10. I'd say it's good to go.

sgress454 added a commit that referenced this pull request Jan 8, 2016
Properly add/cleanup process event listeners.
@sgress454 sgress454 merged commit 85ea87e into balderdashy:master Jan 8, 2016
sgress454 added a commit that referenced this pull request Jan 9, 2016
ctartist621 pushed a commit to ctartist621/sails that referenced this pull request Feb 3, 2016
lennym pushed a commit to lennym/sails that referenced this pull request Feb 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants