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

Add support for regex filter #37

Open
rleungx opened this issue Sep 23, 2019 · 8 comments
Open

Add support for regex filter #37

rleungx opened this issue Sep 23, 2019 · 8 comments

Comments

@rleungx
Copy link

rleungx commented Sep 23, 2019

Considering that we may depend on some other repositories, but we don't care too much about those repos. An alternative would be to support regex filter.

@prashantv
Copy link
Collaborator

Substring and regex filters seem OK, but it might be better to start with an explicit "IgnorePackage".

Putting more generic skips makes it easier to accidentally ignore real leaks as well, so want to make it more specific to the type of leak being ignored.

@ysmood

This comment has been minimized.

@prashantv
Copy link
Collaborator

Is the server under control of the test? If so, closing the server will also close any keep-alive connections, and should avoid leaks. If the server is not under control of the test, but the client is, then the CloseIdleConnections methods can be used to close the idle connections:
https://golang.org/pkg/net/http/#Client.CloseIdleConnections
https://golang.org/pkg/net/http/#Transport.CloseIdleConnections

I would highly recommend closing all connections as part of your test cleaning up any created resources, as there definitely can be real leaks missed by ignoring all HTTP read/write goroutines.

@ysmood

This comment has been minimized.

@prashantv
Copy link
Collaborator

On the server side, closing the server will close idle connections, see documentation:
https://golang.org/pkg/net/http/#Server.Close
https://golang.org/pkg/net/http/#Server.Shutdown

@ysmood

This comment has been minimized.

@prashantv
Copy link
Collaborator

That code actually has a leak -- it's not closing the response body. The leak is not an idle connection, but an active connection for a request that hasn't completed, because the response body has not been read and closed. Add a resp.Body.Close() and the leak will go away.

@ysmood

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants