Skip to content

bug: 🐛 token refresh is not triggered causing need to re-login every ~7 days #163

@clins1994

Description

@clins1994

note: on june 7th i've torn down the bridge and ran it on a clean slate. i will check back on june 14th and provide a more detailed picture then

Bug Report: token refresh is not triggered causing need to re-login every ~7 days

Describe the bug

Some bridge paths do not recover when LINE returns an expired-access-token error. Users can end up needing to manually relogin after the access token
expires, commonly reported as every 7 days / 168 hours.

I recently hit this on my own bridge. The bridge process was still running and Matrix websocket reconnects were working, but an outbound Matrix -> LINE
send failed because LINE returned:

code=10051
TalkException code=119
reason="Access token refresh required"

The bridge already has refresh-token plumbing, but it appears to be applied inconsistently. In particular, the outbound send path can return the SendMessage auth error directly instead of refreshing the token and retrying once.

To Reproduce

  1. Login to LINE through the bridge.
  2. Keep the bridge running until the LINE access token expires, or otherwise trigger a LINE API call with an expired access token.
  3. Send a message from Matrix to LINE.
  4. Observe that the send fails with Access token refresh required instead of refreshing and retrying automatically.

Expected behavior

The bridge should either:

  1. Refresh the LINE access token proactively before expiry using token metadata such as durationUntilRefreshInSec, or
  2. Refresh and retry once when any LINE API call returns code=119 / Access token refresh required.

The user should not need to manually relogin when a valid refresh token is available.

Screenshots or logs

Sanitized log excerpt from my bridge:

{"level":"error","action":"handle matrix event","event_type":"m.room.message","error":"API error 400: {\"code\":10051,\"message\":\"RESPONSE_ERROR\",
\"data\":{\"name\":\"TalkException\",\"message\":\"TalkException\",\"code\":119,\"reason\":\"Access token refresh required\",
\"parameterMap\":null}}","time":"2026-05-28T04:24:27.218385332Z","message":"Failed to handle Matrix message"}
{"level":"debug","action":"handle matrix event","status_code":200,"req_body":
{"status":"FAIL_RETRIABLE","reason":"m.event_not_handled","internal_error":"API error 400: {\"code\":10051,\"message\":\"RESPONSE_ERROR\",\"data\":
{\"name\":\"TalkException\",\"message\":\"TalkException\",\"code\":119,\"reason\":\"Access token refresh required\",
\"parameterMap\":null}}"},"time":"2026-05-28T04:24:28.133625047Z","message":"Request completed"}

Additional context

Relevant code:

Related discussion:
#162

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions