Skip to content
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

Fixes #5034 - change private property io.httpServer to a public property #5035

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ export class Server<
*
*/
public engine: BaseServer;
/**
* The underlying Node.js HTTP server.
*
* @see https://nodejs.org/api/http.html
*/
public httpServer: TServerInstance;

/** @private */
readonly _parser: typeof parser;
Expand Down Expand Up @@ -209,7 +215,6 @@ export class Server<
* @private
*/
_connectTimeout: number;
private httpServer: TServerInstance;
private _corsMiddleware: (
req: http.IncomingMessage,
res: http.ServerResponse,
Expand Down
7 changes: 3 additions & 4 deletions test/support/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SocketOptions,
} from "socket.io-client";
import request from "supertest";
import type { AddressInfo } from "node:net";
import type { DefaultEventsMap, EventsMap } from "../../lib/typed-events";

const expect = require("expect.js");
Expand Down Expand Up @@ -40,8 +41,7 @@ export function createClient<
nsp: string = "/",
opts?: Partial<ManagerOptions & SocketOptions>
): ClientSocket<STC, CTS> {
// @ts-ignore
const port = io.httpServer.address().port;
const port = (io.httpServer.address() as AddressInfo).port;
return ioc(`http://localhost:${port}${nsp}`, opts);
}

Expand Down Expand Up @@ -74,8 +74,7 @@ export function assert(condition: any): asserts condition {
}

export function getPort(io: Server): number {
// @ts-ignore
return io.httpServer.address().port;
return (io.httpServer.address() as AddressInfo).port;
}

export function createPartialDone(count: number, done: (err?: Error) => void) {
Expand Down