Skip to content

[Bug]: Playground /execute endpoint returns oversized response causing RangeError: Invalid string length #2539

Description

@dinghao-8

Version

"@midscene/playground": "^1.8.4"
"@midscene/android": "^1.8.4"
"@midscene/shared": "^1.8.4"

Details

Details
When calling the /execute endpoint, the playground server constructs a response with dump and reportHTML fields that include base64-inlined screenshots (inlineScreenshots: true). After a case with multiple actions executes, the response object becomes extremely large (>50MB), causing JSON.stringify to throw RangeError: Invalid string length inside ServerResponse.json().

Stack trace:

RangeError: Invalid string length
at JSON.stringify ()
at ServerResponse.json
at .../dist/lib/server.js:774-783

Root cause found in source code:

node_modules/@midscene/playground/dist/lib/server.js lines 774-783:

const dumpString = agent.dumpDataString({
inlineScreenshots: true
});
// ...
response.reportHTML = agent.reportHTMLString({
inlineScreenshots: true
});

inlineScreenshots: true is hardcoded, not configurable via request parameters. Even when sending screenshotIncluded: false in the request body, the dump and reportHTML fields still embed base64 screenshots, making the response grow linearly with the number of executed actions.

Reproduce link

Related issues #1439 (same error, closed without fix)

Reproduce Steps

Any /execute call with a case that performs many actions (e.g., multiple swipe operations) will eventually trigger this error as the dump field accumulates screenshot data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions