fix: add timeout to app.close()
Signed-off-by: YxnnXriel <yannariel13@gmail.com>
This commit is contained in:
1 parent
7518a5a785
commit
3dcf784159
3 files changed
+77
-14
No files matched your search
@@ -466,6 +466,27 @@ describe('graceful shutdown', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('close({ timeoutMs }) forces shutdown when a handler never responds', async () => {
|
||||
@Route('/')
|
||||
class Ctl {
|
||||
@Get('/hang') hang() {
|
||||
return new Promise(() => {}); // never resolves — simulates a stuck handler
|
||||
}
|
||||
}
|
||||
@Module({ mountpoint: '/', controllers: [Ctl] })
|
||||
class M {}
|
||||
const app = createApp({ modules: [M] });
|
||||
const server = await app.listen(0);
|
||||
const port = (server.address() as any).port;
|
||||
|
||||
fetch(`http://127.0.0.1:${port}/hang`).catch(() => {});
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
|
||||
const start = Date.now();
|
||||
await app.close({ timeoutMs: 300 });
|
||||
expect(Date.now() - start).toBeLessThan(600);
|
||||
});
|
||||
|
||||
describe('overrides', () => {
|
||||
const portOf = (s: any) => (s.address() as any).port;
|
||||
it('overrides a provider token with a plain value (wrapped as a merge object)', async () => {
|
||||
|
||||
Reference in new issue
Block a user