Skip to content

Commit 83c01bd

Browse files
V48 (impl-only): Fix Error cause options for CI TypeScript target
Avoid new Error(message, { cause }) which fails tsc with Expected 0-1 arguments on the package lib target used by Gate Quality / api build.
1 parent 27fec65 commit 83c01bd

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/generic-hosts/VercelSandbox/src/__tests__/vercel-sandbox-host.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ describe('VercelSandboxPipelineHost', () => {
426426
response: { status: 400, statusText: 'Bad Request' },
427427
json: { error: { code: 'invalid_image', message: 'image not found in project' } },
428428
});
429-
const wrapped = new Error('wrapper', { cause: apiError });
429+
const wrapped = new Error('wrapper') as Error & { cause?: unknown };
430+
wrapped.cause = apiError;
430431
const message = formatSandboxApiError(wrapped, 'Sandbox.create');
431432
expect(message).toContain('Sandbox.create failed');
432433
expect(message).toContain('HTTP 400');

packages/generic-hosts/VercelSandbox/src/vercel-sandbox-host.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ export class VercelSandboxPipelineHost {
8282
message,
8383
httpStatus,
8484
});
85-
throw new Error(message, { cause: error });
85+
// Assign cause without Error constructor options (lib target may be < ES2022).
86+
const wrapped = new Error(message) as Error & { cause?: unknown };
87+
wrapped.cause = error;
88+
throw wrapped;
8689
}
8790
const sandboxIdentity = resolveSandboxIdentity(sandbox, createOptions.name);
8891
await this.emit({

0 commit comments

Comments
 (0)