fix(nextjs-size-limit): surface 413s accurately#2265
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile OverviewGreptile SummaryAdded comprehensive error handling for Next.js 10MB request body size limits to prevent truncated payloads and provide accurate 413 error reporting. Key Changes:
Implementation Approach:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client as Client/Executor
participant executeTool as executeTool()
participant handler as Request Handler
participant validate as validateRequestBodySize()
participant api as External/Internal API
Client->>executeTool: Call with toolId & params
executeTool->>handler: Route to handler (internal/proxy/mcp)
alt Before Request
handler->>validate: Check body size
validate->>validate: Calculate size with Blob API
alt Size > 10MB
validate-->>handler: throw Error(user-friendly message)
handler-->>executeTool: Return error response
executeTool-->>Client: Return ToolResponse with error
end
end
handler->>api: Send request
alt Response Status 413
api-->>handler: HTTP 413 Entity Too Large
handler->>handler: Check response.status === 413
handler-->>executeTool: throw Error(user-friendly message)
executeTool-->>Client: Return ToolResponse with error
end
alt Other Error
api-->>handler: Error response
handler->>handler: catch block
handler->>handler: handleBodySizeLimitError()
alt isBodySizeLimitError = true
handler-->>executeTool: throw Error(user-friendly message)
else Other error
handler-->>executeTool: Re-throw original error
end
executeTool-->>Client: Return ToolResponse with error
end
alt Success
api-->>handler: HTTP 200 OK
handler-->>executeTool: Return success response
executeTool-->>Client: Return ToolResponse with data
end
|
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
Hitting a size limit error randomly truncates payload making error reporting ad hoc.
Type of Change
Testing
Tested with @aadamgough
Checklist