Skip to content

Commit affd70a

Browse files
committed
refactor(common,express): rename graceful shutdown option
Rename gracefulShutdown to return503OnClosing to align the HTTP option name with Fastify's terminology. The previous name was too vague and could imply broader behavior (connection draining, grace periods) beyond what it actually does.
1 parent a1b82bf commit affd70a

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

integration/graceful-shutdown/e2e/express.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ describe('Graceful Shutdown (Express)', () => {
1414
}
1515
});
1616

17-
it('should allow in-flight requests to complete when gracefulShutdown is enabled', async () => {
17+
it('should allow in-flight requests to complete when return503OnClosing is enabled', async () => {
1818
app = await NestFactory.create(AppModule, new ExpressAdapter() as any, {
19-
gracefulShutdown: true,
19+
return503OnClosing: true,
2020
logger: false,
2121
});
2222
await app.listen(0);
@@ -53,7 +53,7 @@ describe('Graceful Shutdown (Express)', () => {
5353

5454
it('should return 503 for NEW queued requests on existing connections during shutdown', async () => {
5555
app = await NestFactory.create(AppModule, new ExpressAdapter() as any, {
56-
gracefulShutdown: true,
56+
return503OnClosing: true,
5757
logger: false,
5858
});
5959
await app.listen(0);

packages/common/interfaces/nest-application-options.interface.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ export interface NestApplicationOptions extends NestApplicationContextOptions {
3131
*/
3232
forceCloseConnections?: boolean;
3333
/**
34-
* Whether to enable graceful shutdown behavior.
35-
* When enabled, the server will return 503 Service Unavailable for new requests
36-
* during the shutdown process, but allow existing in-flight requests to complete.
34+
* Whether to return 503 Service Unavailable for new requests during the shutdown process,
35+
* while allowing existing in-flight requests to complete.
3736
* @default false
3837
*/
39-
gracefulShutdown?: boolean;
38+
return503OnClosing?: boolean;
4039
}

packages/platform-express/adapters/express-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export class ExpressAdapter extends AbstractHttpAdapter<
304304
this.httpServer = http.createServer(this.getInstance());
305305
}
306306

307-
if (options?.gracefulShutdown) {
307+
if (options?.return503OnClosing) {
308308
this.instance.use((req: any, res: any, next: any) => {
309309
if (this.isShuttingDown) {
310310
res.set('Connection', 'close');

0 commit comments

Comments
 (0)