Skip to content

Commit 2645afe

Browse files
committed
fix(sandbox): propagate empty-message broker/fetch errors
Both bridges in the isolate used truthiness to detect host-side errors: if (response.error) throw new Error(response.error); // broker if (result.error) throw new Error(result.error); // fetch If a host handler ever threw `new Error('')`, err.message would be '' (falsy), so { error: '' } was silently swallowed and the isolate saw a successful null result. Existing call sites don't throw empty-message errors, but the pattern was structurally unsafe. Switch both to typeof check === 'string' and fall back to a default message if the string is empty, so all host-reported errors propagate into the isolate regardless of message content. Made-with: Cursor
1 parent e47b27f commit 2645afe

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/sim/lib/execution/isolated-vm-worker.cjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ async function executeCode(request, executionId) {
273273
throw new Error('Invalid fetch response');
274274
}
275275
276-
if (result.error) {
277-
throw new Error(result.error);
276+
if (typeof result.error === 'string') {
277+
throw new Error(result.error || 'Fetch failed');
278278
}
279279
280280
// Create a Response-like object
@@ -775,7 +775,9 @@ async function executeTask(request, executionId) {
775775
);
776776
let response;
777777
try { response = JSON.parse(responseJson); } catch { throw new Error('Invalid broker response'); }
778-
if (response.error) throw new Error(response.error);
778+
if (typeof response.error === 'string') {
779+
throw new Error(response.error || 'Broker call failed');
780+
}
779781
return response.resultJson === undefined || response.resultJson === null
780782
? null
781783
: JSON.parse(response.resultJson);

0 commit comments

Comments
 (0)