fix(messenger): shrink the page list request when Facebook says the response is too large - #1251
Merged
Merged
Conversation
…esponse is too large
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.
Summary
GET /me/accountswith HTTP 500{"error":{"code":1,"message":"Please reduce the amount of data you're asking for, then retry your request"}}, the page picker route throws, and they land on the generic "Something went wrong" boundary with no way forward.limit=100 × 20 requestswalk is kept at every page size.messenger.selectPage.loadFailedis only used when there was no Graph error body to quote (timeout, DNS, malformed JSON).Changes
Messenger integration
integrations/messenger/src/lib/http-client.ts—isDataTooLargeGraphError(code 1, no subcode, Meta's "reduce the amount of data" sentence) andshouldRetryGraphRequest, wired into the shared kyretry.shouldRetry. Returnsundefinedfor everything else so the existing status-code policy is untouched for all three Graph clientsintegrations/messenger/src/apis/auth.ts—fetchDirectPageswalks/me/accountsthroughDIRECT_PAGES_PAGE_LIMITS = [50, 25, 10], restarting from the first page on each shrink;maxPagesscales with the page size so the row ceiling stays at 2000. Any other error is thrown unchangedBuilder
apps/builder/src/app/(no-sidebar)/channels/messenger/select/page.tsx—loadUserPagescatches the failure, maps it throughmapToChannelError, logs it (errkey) and renders the empty picker with the provider's message.readProviderMessageusesUNKNOWN_ERROR.codefrom the SDK to tell "Graph answered" from "Graph never answered"apps/builder/src/features/integration-messenger/components/select-account.tsx— optionalloadErrorprop rendered as a destructive Alert above the pickerapps/builder/messages/*.json—messenger.selectPage.loadFailedin all 20 localesBehaviour changes worth knowing
/me/accountsis requested withlimit=50instead of100for every Messenger connect, so a user with more than 50 pages now makes one extra Graph call on the happy pathconnect-page.tsandreconnect-callback.tsalso callgetUserPages; their contract ({ pages, bmLookupFailed }or a thrownMessengerAPIException) is unchanged, they simply benefit from the smaller pagesTest plan
pnpm --filter @chatbotx.io/integration-messenger test— 36 files, 303/303apps/builder/__tests__/messenger-select-page.test.tsx,messenger-select-account.test.tsx,messenger-pages.test.tsx— 21/21pnpm lint(Biome, i18n-check, schema drift) cleanpnpm --filter @chatbotx.io/integration-messenger check-types,pnpm --filter builder check-types— no errors in touched filesmessenger.selectPage.loadFailedpresent in all 20 files underapps/builder/messages/invariant-guardclean on the difflimit > 10: picker shows the pages after the 50 → 25 → 10 backoff; with every size faked, the red box shows Meta's sentence above the empty state