Skip to content

net/http: consider making Transport clean up after itself #24739

Open
@FiloSottile

Description

@FiloSottile

If a Transport falls out of scope with idle connections, it will leak.

This is surprising for users (for example #24719), and obscure/inconsistent. os.File closes resources when falling out of scope, and Transport doesn't even have a Close method, only CloseIdleConnections. Idle connections are an implementation detail.

Implementing a finalizer would require making sure that all blocked goroutines don't keep pointers to the Transport itself, which might be hard.

Some previous discussion at #16005.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions