Skip to content

Commit ed37186

Browse files
authored
fix(sveltekit): Don't crash build when CLI credentials are missing (#7846)
Previously, a project build would crash when users didn't specify org, project slugs or auth tokens. This patch fixes that by catching the error and providing additional information to the Sentry CLI error message.
1 parent 398ca0f commit ed37186

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/sveltekit/src/vite/sourceMaps.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function makeCustomSentryVitePlugin(options?: SentryVitePluginOptionsOpti
9494

9595
// We need to start uploading source maps later than in the original plugin
9696
// because SvelteKit is still doing some stuff at closeBundle.
97-
closeBundle: () => {
97+
closeBundle: async () => {
9898
if (!upload) {
9999
return;
100100
}
@@ -131,8 +131,21 @@ export function makeCustomSentryVitePlugin(options?: SentryVitePluginOptionsOpti
131131
}
132132
});
133133

134-
// @ts-ignore - this hook exists on the plugin!
135-
sentryPlugin.writeBundle();
134+
try {
135+
// @ts-ignore - this hook exists on the plugin!
136+
await sentryPlugin.writeBundle();
137+
} catch (_) {
138+
// eslint-disable-next-line no-console
139+
console.warn('[Source Maps Plugin] Failed to upload source maps!');
140+
// eslint-disable-next-line no-console
141+
console.log(
142+
'[Source Maps Plugin] Please make sure, you specified a valid Sentry auth token, as well as your org and project slugs.',
143+
);
144+
// eslint-disable-next-line no-console
145+
console.log(
146+
'[Source Maps Plugin] Further information: https://github.com/getsentry/sentry-javascript/blob/develop/packages/sveltekit/README.md#uploading-source-maps',
147+
);
148+
}
136149
},
137150
};
138151

0 commit comments

Comments
 (0)