Skip to content

TE-12436: fix screenshot upload ECONNRESET for payloads over 2MB#500

Open
shrinishLT wants to merge 1 commit intoLambdaTest:mainfrom
shrinishLT:TE-12436
Open

TE-12436: fix screenshot upload ECONNRESET for payloads over 2MB#500
shrinishLT wants to merge 1 commit intoLambdaTest:mainfrom
shrinishLT:TE-12436

Conversation

@shrinishLT
Copy link
Copy Markdown
Contributor

@shrinishLT shrinishLT commented Apr 16, 2026

Summary

Fixes ECONNRESET / "socket hang up" on /screenshot uploads for any screenshot larger than ~2MB (full-page captures, high-DPI viewports, etc.).

JIRA: TE-12436

Root Cause

form-data v4.x defaults maxDataSize to 2 * 1024 * 1024 (2 MB). httpClient.uploadScreenshot did not override it, and — unlike the other upload paths in the same file — also did not set axios maxBodyLength / maxContentLength.

When the combined stream detected the overflow mid-upload, CombinedStream aborted the stream, the server saw a truncated body, and the TCP connection was reset. The axios config in the failing HYE log confirms this:

"_valueLength": 2114763,
"dataSize": 0,
"maxDataSize": 2097152,      // form-data default (2 MB)
"maxContentLength": -1,       // axios default
"maxBodyLength": -1,          // axios default
"code": "ECONNRESET"

The screenshot in the failing log was 2,114,763 bytes — only ~17 KB over the 2 MB form-data limit.

Fix

In src/lib/httpClient.ts uploadScreenshot:

  1. Set form.maxDataSize = Infinity on the FormData instance so form-data does not abort large payloads.
  2. Set maxBodyLength: Infinity and maxContentLength: Infinity on the axios request.

This matches what the other upload methods (log upload, S3 upload) in the same file already do.

Test plan

  • Upload a screenshot > 2 MB and confirm it succeeds (previously ECONNRESET).
  • Upload a screenshot < 2 MB and confirm existing behavior is unchanged.
  • Run an end-to-end SmartUI build with a full-page + retina capture workflow and confirm no retries are triggered by upload errors.
  • Verify HYE webscanner job that previously failed now completes successfully.

Related

Internal RFC: internal-docs RFC-TE-12436-smartui-cli-screenshot-upload-2mb-limit.md

🤖 Generated with Claude Code

Screenshots larger than ~2MB failed with "socket hang up" because form-data
defaults maxDataSize to 2MB and the /screenshot request did not override axios
maxBodyLength/maxContentLength. CombinedStream aborted mid-upload, the server
saw a truncated body, and the TCP connection was reset.

Set form.maxDataSize = Infinity and pass maxBodyLength/maxContentLength =
Infinity on the axios request, matching the other upload paths in this file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants