Compare commits

...

4 Commits

Author SHA1 Message Date
Damien Arrachequesne
1fad7e65be fix(types): properly import http module
Fixes `Module '"http"' has no default export.` errors.
2026-01-07 08:48:25 +01:00
Damien Arrachequesne
9978574e4f chore(release): socket.io@4.8.3
Diff: https://github.com/socketio/socket.io/compare/socket.io@4.8.2...socket.io@4.8.3
2025-12-23 17:39:51 +01:00
Damien Arrachequesne
e9e5bed4f2 chore(release): socket.io-client@4.8.3
Diff: https://github.com/socketio/socket.io/compare/socket.io-client@4.8.2...socket.io-client@4.8.3
2025-12-23 17:36:53 +01:00
Damien Arrachequesne
9581f9bcfd fix(sio): do not throw when calling io.close() on a stopped server
Following [1], calling both `io.close()` and `httpServer.close()` would throw an ERR_SERVER_NOT_RUNNING exception, which was not the case before.

Related: https://github.com/socketio/socket.io/issues/5431

[1]: bb0b480d2a
2025-12-23 17:30:15 +01:00
15 changed files with 80 additions and 26 deletions

View File

@@ -2,7 +2,8 @@
| Version | Release date | Bundle size (UMD min+gzip) |
|-------------------------------------------------------------------------------------------------------------|----------------|----------------------------|
| [4.8.2](#482-2025-12-22) | December 2024 | `14.4 KB` |
| [4.8.3](#483-2025-12-23) | December 2025 | `14.4 KB` |
| [4.8.2](#482-2025-12-22) | December 2025 | `14.4 KB` |
| [4.8.1](#481-2024-10-25) | October 2024 | `14.4 KB` |
| [4.8.0](#480-2024-09-21) | September 2024 | `14.4 KB` |
| [4.7.5](#475-2024-03-14) | March 2024 | `14.6 KB` |
@@ -51,6 +52,18 @@
| [2.1.0](#210-2018-03-29) | March 2018 | `18.7 KB` |
## [4.8.3](https://github.com/socketio/socket.io/compare/socket.io-client@4.8.2...socket.io-client@4.8.3) (2025-12-23)
There were some minor bug fixes on the server side, which mandate a client bump.
### Dependencies
- [`engine.io-client@~6.6.1`](https://github.com/socketio/engine.io-client/releases/tag/6.5.2) (no change)
- [`ws@~8.18.3`](https://github.com/websockets/ws/releases/tag/8.18.3) ([diff](https://github.com/websockets/ws/compare/8.17.1...8.18.3))
## [4.8.2](https://github.com/socketio/socket.io/compare/socket.io-client@4.8.1...socket.io-client@4.8.2) (2025-12-22)

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,6 +1,6 @@
{
"name": "socket.io-client",
"version": "4.8.2",
"version": "4.8.3",
"description": "Realtime application framework client",
"keywords": [
"realtime",

View File

@@ -1,5 +1,5 @@
{
"name": "socket.io-client",
"version": "4.8.2",
"version": "4.8.3",
"type": "module"
}

View File

@@ -2,6 +2,7 @@
| Version | Release date |
|--------------------------------------------------------------------------------------------------|----------------|
| [4.8.3](#483-2025-12-23) | December 2025 |
| [4.8.2](#482-2025-12-22) | December 2025 |
| [4.8.1](#481-2024-10-25) | October 2024 |
| [4.8.0](#480-2024-09-21) | September 2024 |
@@ -50,6 +51,21 @@
| [2.1.0](#210-2018-03-29) | March 2018 |
## [4.8.3](https://github.com/socketio/socket.io/compare/socket.io@4.8.2...socket.io@4.8.3) (2025-12-23)
### Bug Fixes
* do not throw when calling io.close() on a stopped server ([9581f9b](https://github.com/socketio/socket.io/commit/9581f9bcfd0c0fa8cb16eae1604c6a727af21efa))
### Dependencies
- [`engine.io@~6.6.0`](https://github.com/socketio/engine.io/releases/tag/6.6.0) (no change)
- [`ws@~8.18.3`](https://github.com/websockets/ws/releases/tag/8.18.3) (no change)
## [4.8.2](https://github.com/socketio/socket.io/compare/socket.io@4.8.1...socket.io@4.8.2) (2025-12-22)
The `url.parse()` function is now deprecated and has been replaced by `new URL()` (see [8af7019](https://github.com/socketio/socket.io/commit/8af70195bb8c5bc3efe9685997ab6373fb8b1ca9)).

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,5 +1,5 @@
/*!
* Socket.IO v4.8.2
* Socket.IO v4.8.3
* (c) 2014-2025 Guillermo Rauch
* Released under the MIT License.
*/

View File

@@ -1,4 +1,9 @@
import http from "http";
import { createServer } from "http"; // 'node:' prefix was added in Node.js 16
import type {
Server as HTTPServer,
IncomingMessage,
ServerResponse,
} from "http";
import type { Server as HTTPSServer } from "https";
import type { Http2SecureServer, Http2Server } from "http2";
import { createReadStream } from "fs";
@@ -58,7 +63,7 @@ type ParentNspNameMatchFn = (
type AdapterConstructor = typeof Adapter | ((nsp: Namespace) => Adapter);
type TServerInstance =
| http.Server
| HTTPServer
| HTTPSServer
| Http2SecureServer
| Http2Server;
@@ -276,8 +281,8 @@ export class Server<
*/
_connectTimeout: number;
private _corsMiddleware: (
req: http.IncomingMessage,
res: http.ServerResponse,
req: IncomingMessage,
res: ServerResponse,
next: () => void,
) => void;
@@ -301,7 +306,7 @@ export class Server<
if (
"object" === typeof srv &&
srv instanceof Object &&
!(srv as Partial<http.Server>).listen
!(srv as Partial<HTTPServer>).listen
) {
opts = srv as Partial<ServerOptions>;
srv = undefined;
@@ -493,7 +498,7 @@ export class Server<
if ("number" == typeof srv) {
debug("creating http server and binding to %d", srv);
const port = srv;
srv = http.createServer((req, res) => {
srv = createServer((_req, res) => {
res.writeHead(404);
res.end();
});
@@ -591,7 +596,7 @@ export class Server<
): void {
// initialize engine
debug("creating engine.io instance with opts %j", opts);
this.eio = attach(srv as http.Server, opts);
this.eio = attach(srv as HTTPServer, opts);
// attach static file serving
if (this._serveClient) this.attachServe(srv);
@@ -638,7 +643,7 @@ export class Server<
* @param res
* @private
*/
private serve(req: http.IncomingMessage, res: http.ServerResponse): void {
private serve(req: IncomingMessage, res: ServerResponse): void {
const filename = req.url!.replace(this._path, "").replace(/\?.*$/, "");
const isMap = dotMapRegex.test(filename);
const type = isMap ? "map" : "source";
@@ -678,8 +683,8 @@ export class Server<
*/
private static sendFile(
filename: string,
req: http.IncomingMessage,
res: http.ServerResponse,
req: IncomingMessage,
res: ServerResponse,
): void {
const readStream = createReadStream(
path.join(__dirname, "../client-dist/", filename),
@@ -831,14 +836,13 @@ export class Server<
restoreAdapter();
if (this.httpServer) {
await new Promise<void>((resolve, reject) => {
return new Promise<void>((resolve) => {
this.httpServer.close((err) => {
fn && fn(err);
if (err) {
reject(err);
} else {
resolve();
debug("server was not running");
}
resolve();
});
});
} else {

View File

@@ -1,6 +1,6 @@
{
"name": "socket.io",
"version": "4.8.2",
"version": "4.8.3",
"description": "node.js realtime framework server",
"keywords": [
"realtime",

View File

@@ -70,6 +70,27 @@ describe("close", () => {
});
});
it("should not throw when the underlying HTTP server is not running (callback)", (done) => {
const httpServer = createServer();
const io = new Server(httpServer);
io.close((err) => {
expect((err as Error & { code: string }).code).to.eql(
"ERR_SERVER_NOT_RUNNING",
);
done();
});
});
it("should not throw when the underlying HTTP server is not running (Promise)", (done) => {
const httpServer = createServer();
const io = new Server(httpServer);
io.close()
.then(() => done())
.catch((e) => done(e));
});
describe("graceful close", () => {
function fixture(filename) {
return (