Skip to content

Response is never closed when the API returns 429, leaking connections #67

Closed

Description

@nachomezzadra

BaseRequest.handleRequest throws RateLimitedException on a 429 without closing the Response. OkHttp never gets the connection back, and later it logs this for every rate-limited call:

WARN okhttp3.OkHttpClient : A connection to https://api.ipinfo.io/ was leaked. Did you forget to close a response body?

Callers can't close it themselves, because the exception doesn't carry the response.

We hit this when our account ran past its monthly quota. Every lookup came back 429, and we got about 2.3M of these warnings in one day. The log volume alone was noticeable on our bill.

The non-2xx branch right below doesn't have the problem, because response.body().string() closes the body. Only the 429 branch skips it.

Seen on 3.4.0 and current master (87511f4). PR with a fix and a test to follow.

Activity

  1. linear-code commented on Oct 30, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions