@twin.org/api-server-fastify 0.9.1-next.5 → 0.9.1-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,13 +8,17 @@ const fastifySocketIO = fp(async (fastify, opts) => {
8
8
  const ioServer = new Server(fastify.server, opts);
9
9
  fastify.decorate("io", ioServer);
10
10
  fastify.addHook("preClose", done => {
11
- ioServer.disconnectSockets();
12
- ioServer
13
- .close()
14
- // eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise
15
- .then(() => done())
16
- // eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise
17
- .catch(() => done());
11
+ // Close transports immediately rather than waiting for clients to ack,
12
+ // so shutdown is not held up by unresponsive connections.
13
+ ioServer.disconnectSockets(true);
14
+ // Safety net: if ioServer.close() never resolves (e.g. a socket hangs),
15
+ // call done() after 2.5s so Fastify shutdown can still complete.
16
+ const timeout = setTimeout(() => done(), 2500);
17
+ setTimeout(async () => {
18
+ await ioServer.close();
19
+ clearTimeout(timeout);
20
+ done();
21
+ }, 0);
18
22
  });
19
23
  }, { fastify: ">=5.x.x", name: "socket.io" });
20
24
  export default fastifySocketIO;
@@ -1 +1 @@
1
- {"version":3,"file":"fastifySocketIo.js","sourceRoot":"","sources":["../../src/fastifySocketIo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAsB,MAAM,WAAW,CAAC;AAEvD;;;GAGG;AACH,MAAM,eAAe,GAA+C,EAAE,CACrE,KAAK,EAAE,OAAwB,EAAE,IAA4B,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE;QAClC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAC7B,QAAQ;aACN,KAAK,EAAE;YACR,wFAAwF;aACvF,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;YACnB,wFAAwF;aACvF,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACJ,CAAC,EACD,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CACzC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fp from \"fastify-plugin\";\nimport { Server, type ServerOptions } from \"socket.io\";\n\n/**\n * Fastify plugin that attaches a Socket.IO server to the Fastify HTTP server.\n * Cloned from fastify-socket.io to support recent Fastify versions.\n */\nconst fastifySocketIO: FastifyPluginAsync<Partial<ServerOptions>> = fp(\n\tasync (fastify: FastifyInstance, opts: Partial<ServerOptions>) => {\n\t\tconst ioServer = new Server(fastify.server, opts);\n\n\t\tfastify.decorate(\"io\", ioServer);\n\t\tfastify.addHook(\"preClose\", done => {\n\t\t\tioServer.disconnectSockets();\n\t\t\tioServer\n\t\t\t\t.close()\n\t\t\t\t// eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise\n\t\t\t\t.then(() => done())\n\t\t\t\t// eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise\n\t\t\t\t.catch(() => done());\n\t\t});\n\t},\n\t{ fastify: \">=5.x.x\", name: \"socket.io\" }\n);\n\nexport default fastifySocketIO;\n"]}
1
+ {"version":3,"file":"fastifySocketIo.js","sourceRoot":"","sources":["../../src/fastifySocketIo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAsB,MAAM,WAAW,CAAC;AAEvD;;;GAGG;AACH,MAAM,eAAe,GAA+C,EAAE,CACrE,KAAK,EAAE,OAAwB,EAAE,IAA4B,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE;QAClC,uEAAuE;QACvE,0DAA0D;QAC1D,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEjC,wEAAwE;QACxE,iEAAiE;QACjE,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;QAC/C,UAAU,CAAC,KAAK,IAAI,EAAE;YACrB,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;YACvB,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,EAAE,CAAC;QACR,CAAC,EAAE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACJ,CAAC,EACD,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CACzC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fp from \"fastify-plugin\";\nimport { Server, type ServerOptions } from \"socket.io\";\n\n/**\n * Fastify plugin that attaches a Socket.IO server to the Fastify HTTP server.\n * Cloned from fastify-socket.io to support recent Fastify versions.\n */\nconst fastifySocketIO: FastifyPluginAsync<Partial<ServerOptions>> = fp(\n\tasync (fastify: FastifyInstance, opts: Partial<ServerOptions>) => {\n\t\tconst ioServer = new Server(fastify.server, opts);\n\n\t\tfastify.decorate(\"io\", ioServer);\n\t\tfastify.addHook(\"preClose\", done => {\n\t\t\t// Close transports immediately rather than waiting for clients to ack,\n\t\t\t// so shutdown is not held up by unresponsive connections.\n\t\t\tioServer.disconnectSockets(true);\n\n\t\t\t// Safety net: if ioServer.close() never resolves (e.g. a socket hangs),\n\t\t\t// call done() after 2.5s so Fastify shutdown can still complete.\n\t\t\tconst timeout = setTimeout(() => done(), 2500);\n\t\t\tsetTimeout(async () => {\n\t\t\t\tawait ioServer.close();\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tdone();\n\t\t\t}, 0);\n\t\t});\n\t},\n\t{ fastify: \">=5.x.x\", name: \"socket.io\" }\n);\n\nexport default fastifySocketIO;\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.1-next.7](https://github.com/iotaledger/twin-api/compare/api-server-fastify-v0.9.1-next.6...api-server-fastify-v0.9.1-next.7) (2026-07-02)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * socket.io cleanup ([554324c](https://github.com/iotaledger/twin-api/commit/554324c0349a79b6722e32f042fc0a77572b4c9b))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-core bumped from 0.9.1-next.6 to 0.9.1-next.7
16
+ * @twin.org/api-models bumped from 0.9.1-next.6 to 0.9.1-next.7
17
+ * @twin.org/api-processors bumped from 0.9.1-next.6 to 0.9.1-next.7
18
+
19
+ ## [0.9.1-next.6](https://github.com/iotaledger/twin-api/compare/api-server-fastify-v0.9.1-next.5...api-server-fastify-v0.9.1-next.6) (2026-06-30)
20
+
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * **api-server-fastify:** Synchronize repo versions
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/api-core bumped from 0.9.1-next.5 to 0.9.1-next.6
32
+ * @twin.org/api-models bumped from 0.9.1-next.5 to 0.9.1-next.6
33
+ * @twin.org/api-processors bumped from 0.9.1-next.5 to 0.9.1-next.6
34
+
3
35
  ## [0.9.1-next.5](https://github.com/iotaledger/twin-api/compare/api-server-fastify-v0.9.1-next.4...api-server-fastify-v0.9.1-next.5) (2026-06-30)
4
36
 
5
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-server-fastify",
3
- "version": "0.9.1-next.5",
3
+ "version": "0.9.1-next.7",
4
4
  "description": "Fastify web server integration for exposing API routes with consistent runtime behaviour.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,9 +16,9 @@
16
16
  "dependencies": {
17
17
  "@fastify/compress": "9.0.0",
18
18
  "@fastify/cors": "11.2.0",
19
- "@twin.org/api-core": "0.9.1-next.5",
20
- "@twin.org/api-models": "0.9.1-next.5",
21
- "@twin.org/api-processors": "0.9.1-next.5",
19
+ "@twin.org/api-core": "0.9.1-next.7",
20
+ "@twin.org/api-models": "0.9.1-next.7",
21
+ "@twin.org/api-processors": "0.9.1-next.7",
22
22
  "@twin.org/context": "next",
23
23
  "@twin.org/core": "next",
24
24
  "@twin.org/logging-models": "next",