Skip to content

fix: pass arguments to server.close #635

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KoltesDigital
Copy link

Please ensure that your pull request fulfills these requirements:

  • The pull request is being made against the master branch
  • Tests for the changes have been added (for bug fixes / features)

What is the purpose of this pull request? (bug fix, enhancement, new feature,...)

Rather bug fix.

What changes did you make?

As for server.listen, server.close (both for HTTP and HTTPS servers, as returned by union) takes an optional callback which is called on completion or error. This patch adds argument forwarding for close.

Provide some example code that this change will affect, if applicable:

	const server = createServer({
		root: path.join(__dirname, '..', 'files'),
	});

	await new Promise((resolve) => server.listen(port, resolve));
	
	...

	await new Promise((resolve) => server.close(resolve as any));

Is there anything you'd like reviewers to focus on?

Well there's no tests, should I somehow write one?

As a side note, HttpServer.prototype.close forwards the return value of this.server.close, i.e. this. But HttpServer.prototype.listen does not. I think it should too.

Please provide testing instructions, if applicable:

Above code.

Copy link
Member

@thornjad thornjad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this!

All that's left to do:

  • merge master and let the new tests run (we've changed a lot since this PR was opened)
  • add at least one test to ensure arguments are passed properly. This is less about testing your changes, more about ensuring future changes don't break this

@thornjad thornjad added the minor version non-breaking, non-trivial change label Sep 13, 2021
@thornjad thornjad added the fix label Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix minor version non-breaking, non-trivial change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants