Skip to content

Commit ec83479

Browse files
committed
fix(execution): word payload-limit errors for files too and never print a size equal to the limit
1 parent 0db70fa commit ec83479

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎apps/sim/lib/execution/resource-errors.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ const GENERIC_LIMIT_MESSAGE = 'Execution memory limit exceeded. Reduce payload s
2121
/**
2222
* A payload refusal names the value's size and the limit, so whoever fixes the workflow
2323
* (a person or Chat) can see it is a structural problem rather than retrying it. A Redis
24-
* budget's byte counts describe a write chunk, which means nothing to a user, and a
25-
* payload size that is only known to exceed the limit (`limit + 1`) is left unstated.
24+
* budget's byte counts describe a write chunk, which means nothing to a user. A size
25+
* that reads the same as the limit (only known to exceed it, or just over) is left unstated.
2626
*/
2727
function getResourceLimitMessage(details: ExecutionResourceLimitDetails): string {
2828
if (details.resource !== 'execution_payload_bytes') return GENERIC_LIMIT_MESSAGE
29-
const limit = formatLargeValueSize(details.limitBytes)
30-
if (details.attemptedBytes <= details.limitBytes + 1) {
31-
return `Execution memory limit exceeded: a value is larger than the ${limit} limit. Reference a smaller field, or have the blocks that produce it output less.`
32-
}
33-
return `Execution memory limit exceeded: a value is ${formatLargeValueSize(details.attemptedBytes)}, more than the ${limit} limit. Reference a smaller field, or have the blocks that produce it output less.`
29+
const limit = formatSize(details.limitBytes)
30+
const attempted = formatSize(details.attemptedBytes)
31+
const size = attempted === limit ? 'is larger than' : `is ${attempted}, more than`
32+
return `Execution memory limit exceeded: the data ${size} the ${limit} limit. Pass a smaller field or file, or have the blocks that produce it output less.`
33+
}
34+
35+
function formatSize(bytes: number): string {
36+
return bytes < 1024 * 1024 ? `${Math.ceil(bytes / 1024)} KB` : formatLargeValueSize(bytes)
3437
}
3538

3639
export class ExecutionResourceLimitError extends Error {

‎apps/sim/lib/function-execution/execute-request.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ describe('Function execution request', () => {
28052805

28062806
const data = await response.json()
28072807
expect(data.output.result).toBe(
2808-
'Execution memory limit exceeded: a value is 28.0 MB, more than the 16.0 MB limit. Reference a smaller field, or have the blocks that produce it output less.'
2808+
'Execution memory limit exceeded: the data is 28.0 MB, more than the 16.0 MB limit. Pass a smaller field or file, or have the blocks that produce it output less.'
28092809
)
28102810
})
28112811
})

0 commit comments

Comments
 (0)