Skip to content

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