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

Don't re-initialize the server #3057

Merged
merged 2 commits into from Mar 9, 2016
Merged

Don't re-initialize the server #3057

merged 2 commits into from Mar 9, 2016

Conversation

@gergoerdosi
Copy link
Contributor

@gergoerdosi gergoerdosi commented Feb 24, 2016

I often run into issues in tests when server.initialize() is called multiple times. At the moment an error is thrown when it happens:

Cannot initialize server while it is in initialized state

This PR changes the behavior, when the server is in initialized state, it doesn't attempt to run the initialization process again, it just calls the callback. I opened this PR to receive initial feedback, happy to improve it later.

@@ -185,6 +185,10 @@ internals.Server.prototype.initialize = function (callback) {
return errorCallback(new Error('Cannot start server before plugins finished registration'));
}

if (this._state === 'initialized') {
return callback();
Copy link
Contributor

@hueniverse hueniverse Feb 25, 2016

Technically it should use the errorCallback after renaming it to nextTickCallback

Copy link
Contributor Author

@gergoerdosi gergoerdosi Feb 25, 2016

Renamed errorCallback to nextTickCallback.

@hueniverse hueniverse added the bug label Mar 9, 2016
@hueniverse hueniverse added this to the 13.1.0 milestone Mar 9, 2016
@hueniverse hueniverse self-assigned this Mar 9, 2016
hueniverse added a commit that referenced this issue Mar 9, 2016
Don't re-initialize the server
@hueniverse hueniverse merged commit b96a8c6 into hapijs:master Mar 9, 2016
1 check passed
@lock
Copy link

@lock lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants