Skip to content

Commit f24cfb2

Browse files
authored
fix: shutdown server Sentry SDK when nuxt build is done (#551)
1 parent 3597f0e commit f24cfb2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/module.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ export default defineNuxtModule<ModuleConfiguration>({
142142
// the release version has been determined and the options template created but before
143143
// the build is started (if building).
144144
if (isNuxt2()) {
145-
const initHook = nuxt.options._build ? 'build:compile' : 'ready'
145+
const isBuilding = nuxt.options._build
146+
const initHook = isBuilding ? 'build:compile' : 'ready'
146147
nuxt.hook(initHook, () => initializeServerSentry(nuxt, options, sentryHandlerProxy, logger))
148+
const shutdownHook = isBuilding ? 'build:done' : 'close'
147149
const shutdownServerSentryOnce = callOnce(() => shutdownServerSentry())
148-
nuxt.hook('generate:done', shutdownServerSentryOnce)
149-
nuxt.hook('close', shutdownServerSentryOnce)
150+
nuxt.hook(shutdownHook, shutdownServerSentryOnce)
150151
}
151152
}
152153

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"./test/",
2525
],
2626
"exclude": [
27-
"./dist",
27+
"**/dist",
2828
"./node_modules/",
2929
"./src/templates/client.*.js",
3030
"./src/templates/plugin.*.js",

0 commit comments

Comments
 (0)