-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): change listen to reject on server bind failures #3360
feat(core): change listen to reject on server bind failures #3360
Conversation
Pull Request Test Coverage Report for Build f53a9d1a-cad8-4ba0-b94c-921bd5f9b973
💛 - Coveralls |
packages/core/nest-application.ts
Outdated
if (address) { | ||
this.httpServer.removeListener('error', errorHandler); | ||
this.isListening = true; | ||
this.logger.log(`Server listening at ${this.formatAddress(address)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to don't log anything automatically leaving this decision to the developer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the automatic log here.
packages/core/nest-application.ts
Outdated
resolve(this.httpServer); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
public listenAsync(port: number | string, hostname?: string): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can be depracated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed listenAsync function.
callback?: () => void, | ||
): Promise<any>; | ||
public async listen(port: number | string): Promise<any>; | ||
public async listen(port: number | string, hostname: string): Promise<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to update INestApplication
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated👍
import { AppModule } from '../src/app.module'; | ||
import { INestApplication } from '@nestjs/common'; | ||
|
||
describe('Listen (Express Application', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fastify
here instead of Express
, and add missing closing parentheses
import { AppModule } from '../src/app.module'; | ||
import { INestApplication } from '@nestjs/common'; | ||
|
||
describe('Listen (Express Application', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add missing closing parentheses
ec75e10
to
b986129
Compare
b986129
to
4cc2d18
Compare
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Updates the app listen function to return a promise. Allows developer to see http bind errors and handle them when calling
app.listen()
. Also logs url on successful server startup.What is the current behavior?
The app would exit silently if the server failed to bind.
Issue 3209
Issue Number: 3209
What is the new behavior?
Updates the app listen function to return a promise. Allows developer to see http bind errors and handle them when calling
app.listen()
. Also logs url on successful server startup.Does this PR introduce a breaking change?
Other information