MuckRock / documentcloud-frontend

DocumentCloud's front end source code - Please report bugs, issues and feature requests to info@documentcloud.org
https://www.documentcloud.org
GNU Affero General Public License v3.0
17 stars 5 forks source link

Crashing on load failure #837

Open eyeseast opened 1 day ago

eyeseast commented 1 day ago

This page is crashing: https://next.www.documentcloud.org/documents/4448659-2017-EPA-Staff-Calendars-Part2-S/

Logs:

Nov 15, 04:51:15 PM: [ERROR] [1731707475269] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 413.

Not sure what that means. The response is failing before it gets to Cloudflare.

eyeseast commented 1 day ago

This is the underlying error:

Function.ResponseSizeTooLarge - Response payload size exceeded maximum allowed payload size (6291556 bytes).

So we're somehow sending a giant response.

eyeseast commented 1 day ago

I think the issue is all the fetch data that gets rendered into the page. View source on this for an example: https://next.www.documentcloud.org/documents/23813897-mueller/. That page is more than 2 mb, and Lambda functions have a hard 6 mb limit.

eyeseast commented 1 day ago

I bet it's the text. Since we're fetching it all, it gets rendered on the page. That document is 1,774 long, which is a lot of text to dump on the page.

eyeseast commented 1 day ago

One idea: We load only the first page of text on the server, and then load the full text in onMount. We still get some SEO benefit, but we're not sending all that text through Lambda. Need to see how this messes with pagination, though. We couldn't go to a text page until text is loaded.