Repository navigation
Conversation
Until a response's headers have been parsed, NextRequestTime blocked a policy whenever any request had ever been recorded for it. A request that finished without its headers being read (e.g. the PoE login could not be refreshed) therefore blocked the policy until 2032, so character import refused every request until Path of Building was restarted, even after signing in again. Block only while a request is still pending, which is what the long cooldown is for.
When the PoE API rejected the access token and the refresh failed, DownloadWithRefresh called back without a response, and DownloadWithRateLimit then indexed response.header: In download callback: Classes/PoEAPI.lua:192: attempt to index local 'response' (a nil value) Pass the error on instead, so the Import tab shows "Not authenticated" and the Authorize button.
zediir
marked this pull request as ready for review
November 29, 2026 17:23
Wires77
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the problem being solved:
When the PoE API rejects the saved access token and refreshing it fails (for example the refresh token was revoked by signing in from another install, or PoB was left open past the token's expiry while offline), clicking Start in Character Import crashes:
DownloadWithRefreshcalls back without a response when the refresh fails, andDownloadWithRateLimitthen readsresponse.header.The crash also leaves the rate limiter stuck. The request was recorded but its response headers were never read, so
TradeQueryRateLimiter:NextRequestTimetreats the policy as waiting for its first response and returns its long cooldown (a timestamp in 2032). After signing in again, every character list request is refused with "Requests are being sent too fast, try again in 160555682 seconds" until PoB is restarted.Changes (two commits):
TradeQueryRateLimiter:NextRequestTimeblocks a policy with unknown limits only while one of its requests is still pending, instead of whenever a request was ever recorded.PoEAPI:DownloadWithRateLimitpasses the error on when there is no response. The Import tab then shows "Not authenticated" and the Authorize button.The two belong together: with only the PoEAPI change, the crash is gone but the rate limiter still blocks every request after signing in again.
Steps taken to verify a working solution:
DownloadCharacterList(ondevit fails with the stack trace above), two coverNextRequestTimewith a pending and a finished request. The full busted suite passes in thepathofbuilding-testsimage (906 successes).src/Settings.xml:<Accounts tokenExpiry="<a time in the future>" lastToken="fake-access-token" lastRefreshToken="fake-refresh-token" lastRealm="PoE2"/>. New build, Import/Export Build tab (shows "Authenticated"), click Start.Link to a build that showcases this PR:
Not build-specific.
Before screenshot:
Clicking Start with a token that can't be refreshed:
After dismissing the error and signing in again:
After screenshot:
Clicking Start with a token that can't be refreshed:
After signing in again in the same session:
I made this with the help of an AI assistant (Claude). I don't have much Lua experience, but I have read the changes and understand what each line does and why.