Skip to content

Commit f8d68a1

Browse files
committed
fix(shutdown): handle simultaneous shutdown
1 parent b074ba0 commit f8d68a1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,17 @@ export async function getReusableApp<
166166
}
167167

168168
export async function clearReusableApp() {
169+
const oldApp = app;
170+
app = undefined;
171+
appService = undefined;
169172
try {
170-
if (app) {
171-
await shutdownApp(app);
173+
if (oldApp) {
174+
await shutdownApp(oldApp);
172175
}
173176
} catch (error) {
174177
// eslint-disable-next-line no-console
175178
console.error('Shared app shutdown failed', error);
176179
}
177-
app = undefined;
178-
appService = undefined;
179180
}
180181

181182
export async function getSimulatedContext<Config extends ConfigurationSchema = ConfigurationSchema>(

0 commit comments

Comments
 (0)