Skip to content

Commit 85fcbd4

Browse files
Hage Yaapahacksparrow
authored andcommitted
fix(http-server): reset addressInfo when server is stopped
Reset `addressInfo` when the server is stopped. Currently it returns the old address.
1 parent 8499862 commit 85fcbd4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/http-server/src/http-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class HttpServer {
113113
/**
114114
* Address of the HTTP / HTTPS server
115115
*/
116-
public get address(): AddressInfo {
117-
return this._address;
116+
public get address(): AddressInfo | undefined {
117+
return this._started ? this._address : undefined;
118118
}
119119
}

packages/http-server/test/integration/http-server.integration.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ describe('HttpServer (integration)', () => {
100100
.which.is.an.Object();
101101
});
102102

103+
it('resets address when server is stopped', async () => {
104+
server = new HttpServer(dummyRequestHandler);
105+
await server.start();
106+
expect(server)
107+
.to.have.property('address')
108+
.which.is.an.Object();
109+
await server.stop();
110+
expect(server.address).to.be.undefined();
111+
});
112+
103113
it('exports started', async () => {
104114
server = new HttpServer(dummyRequestHandler);
105115
await server.start();

0 commit comments

Comments
 (0)