Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rethrow functions esbuild errors #5231

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/app/src/cli/services/build/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,16 @@ export async function buildFunctionExtension(
await touchFile(bundlePath)
await writeFile(bundlePath, base64Contents)
}
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
// We capture and rethrow as AbortError to avoid random user-code errors being reported as CLI bugs.
// At the same time, we need to keep the ESBuild details for the logs. (the `errors` array)
const errorMessage = (error as Error).message ?? 'Unknown error occurred'
throw new AbortError('Failed to build function.', errorMessage)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const newError: any = new AbortError('Failed to build function.', errorMessage)
// Inject ESBuild errors if present
newError.errors = error.errors
throw newError
} finally {
await releaseLock()
}
Expand Down
Loading