[PR #2454] [MERGED] Add SocketAuthority.close() #3720

Closed
opened 2026-04-25 00:16:47 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/2454
Author: @mikiher
Created: 12/27/2023
Status: Merged
Merged: 12/28/2023
Merged by: @advplyr

Base: masterHead: socket-authority-close


📝 Commits (2)

  • 21d0d43 Add SocketAuthority.close()
  • 9a634e0 Add JS docs for server stop

📊 Changes

2 files changed (+20 additions, -2 deletions)

View changed files

📝 server/Server.js (+6 -2)
📝 server/SocketAuthority.js (+14 -0)

📄 Description

This is a small fix for my previous PR #2445.

If there are connected SocketIO sockets, then calling server.close() on SIGINT will hang and not resolve.

Instead, we need to call SocketAuthority.io.close(), which will disconnect all connected sockets, and also close the underlying http server (see documentation here). Sorry for missing this initially.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/2454 **Author:** [@mikiher](https://github.com/mikiher) **Created:** 12/27/2023 **Status:** ✅ Merged **Merged:** 12/28/2023 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `socket-authority-close` --- ### 📝 Commits (2) - [`21d0d43`](https://github.com/advplyr/audiobookshelf/commit/21d0d43edc387dac8d4fc9a788a6548a80cda32a) Add SocketAuthority.close() - [`9a634e0`](https://github.com/advplyr/audiobookshelf/commit/9a634e0de576d6e700f3a3a29f1394fc65347432) Add JS docs for server stop ### 📊 Changes **2 files changed** (+20 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `server/Server.js` (+6 -2) 📝 `server/SocketAuthority.js` (+14 -0) </details> ### 📄 Description This is a small fix for my previous PR #2445. If there are connected SocketIO sockets, then calling server.close() on SIGINT will hang and not resolve. Instead, we need to call SocketAuthority.io.close(), which will disconnect all connected sockets, and also close the underlying http server (see documentation [here](https://socket.io/docs/v4/server-api/#serverclosecallback)). Sorry for missing this initially. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:16:47 +02:00
adam closed this issue 2026-04-25 00:16:47 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3720