Skip to content

Commit e729f02

Browse files
authored
fix(webpack): Ensure process exits when done (#653)
1 parent 1547fea commit e729f02

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

packages/bundler-plugin-core/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ interface SentryUnpluginFactoryOptions {
3333
componentNameAnnotatePlugin?: (ignoredComponents?: string[]) => UnpluginOptions;
3434
moduleMetadataInjectionPlugin: (injectionCode: string) => UnpluginOptions;
3535
debugIdInjectionPlugin: (logger: Logger) => UnpluginOptions;
36-
debugIdUploadPlugin: (upload: (buildArtifacts: string[]) => Promise<void>) => UnpluginOptions;
36+
debugIdUploadPlugin: (
37+
upload: (buildArtifacts: string[]) => Promise<void>,
38+
logger: Logger
39+
) => UnpluginOptions;
3740
bundleSizeOptimizationsPlugin: (buildFlags: SentrySDKBuildFlags) => UnpluginOptions;
3841
}
3942

@@ -408,7 +411,8 @@ export function sentryUnpluginFactory({
408411
vcsRemote: options.release.vcsRemote,
409412
headers: options.headers,
410413
},
411-
})
414+
}),
415+
logger
412416
)
413417
);
414418
}

packages/webpack-plugin/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
stringToUUID,
66
SentrySDKBuildFlags,
77
createComponentNameAnnotateHooks,
8+
Logger,
89
} from "@sentry/bundler-plugin-core";
910
import * as path from "path";
1011
import { UnpluginOptions } from "unplugin";
@@ -117,7 +118,8 @@ function webpackDebugIdInjectionPlugin(): UnpluginOptions {
117118
}
118119

119120
function webpackDebugIdUploadPlugin(
120-
upload: (buildArtifacts: string[]) => Promise<void>
121+
upload: (buildArtifacts: string[]) => Promise<void>,
122+
logger: Logger
121123
): UnpluginOptions {
122124
const pluginName = "sentry-webpack-debug-id-upload-plugin";
123125
return {
@@ -133,6 +135,15 @@ function webpackDebugIdUploadPlugin(
133135
callback();
134136
});
135137
});
138+
139+
if (compiler.options.mode === "production") {
140+
compiler.hooks.done.tap(pluginName, () => {
141+
setTimeout(() => {
142+
logger.debug("Exiting process after debug file upload");
143+
process.exit(0);
144+
});
145+
});
146+
}
136147
},
137148
};
138149
}

0 commit comments

Comments
 (0)