Skip to content

Commit f407ecb

Browse files
committed
fix(webpack): Await source map deletion before signaling build completion
This PR reworks the webpack plugin to await the source map deletion before moving on. This matches the behavior of the rollup and esbuild plugins.
1 parent ae53f55 commit f407ecb

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

packages/webpack-plugin/src/webpack4and5.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ export function sentryWebpackPluginFactory({
277277

278278
compiler.hooks.afterEmit.tapAsync(
279279
"sentry-webpack-plugin",
280-
(compilation: WebpackCompilation, callback: () => void) => {
280+
(compilation: WebpackCompilation, callback: (err?: Error) => void) => {
281281
const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
282282
const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
283283

284-
void sentryBuildPluginManager
284+
sentryBuildPluginManager
285285
.createRelease()
286286
.then(async () => {
287287
if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
@@ -292,13 +292,14 @@ export function sentryWebpackPluginFactory({
292292
await upload(buildArtifacts);
293293
}
294294
})
295-
.then(() => {
296-
callback();
297-
})
298-
.finally(() => {
295+
.finally(async () => {
299296
freeGlobalDependencyOnBuildArtifacts();
300-
void sentryBuildPluginManager.deleteArtifacts();
301-
});
297+
await sentryBuildPluginManager.deleteArtifacts();
298+
})
299+
.then(
300+
() => callback(),
301+
(err: Error) => callback(err)
302+
);
302303
}
303304
);
304305

0 commit comments

Comments
 (0)