Szymon Wilczek

research / lavalink-devs/youtube-source / fix / 2be8e542d3f6

cipher: close embed response before getTimestamp to avoid connection starvation

lavalink-devs/youtube-source

fix +6 −1

From: Szymon Wilczek <[email protected]>
Date: 17 Sep 2026
Subject: fix: cipher: close embed response before getTimestamp to avoid connection starvation
Pull request: #245
Merged: 17 Sep 2026, by devoxin

In CipherManager#getPlayerScript, getTimestamp was invoked within the try-with-resources block of the embed CloseableHttpResponse.

Keeping the response open while executing another request on the same HttpInterface can lead to connection pool starvation and socket timeouts.

signed, reported, fixes

  • Author Szymon Wilczek author
  • Merged-by devoxin maintainer · merged it

diff

common/src/main/java/dev/lavalink/youtube/cipher/CipherManager.java +6 −1
@@ -39,16 +39,21 @@ public interface CipherManager {      default CachedPlayerScript getPlayerScript(@NotNull HttpInterface httpInterface) {         synchronized (this) {+            String scriptUrl;             try (CloseableHttpResponse response = httpInterface.execute(new HttpGet("https://www.youtube.com/embed/"))) {                 HttpClientTools.assertSuccessWithContent(response, "fetch player script (embed)");                  String responseText = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);-                String scriptUrl = DataFormatTools.extractBetween(responseText, "\"jsUrl\":\"", "\"");+                scriptUrl = DataFormatTools.extractBetween(responseText, "\"jsUrl\":\"", "\"");                  if (scriptUrl == null) {                     throw new ExceptionWithResponseBody("no jsUrl found", responseText);                 }+            } catch (IOException e) {+                throw ExceptionTools.toRuntimeException(e);+            } +            try {                 return new CachedPlayerScript(scriptUrl, getTimestamp(httpInterface, scriptUrl));             } catch (IOException e) {                 throw ExceptionTools.toRuntimeException(e);

discussion · on the pull request

v1 · 2 messages

szymonwilczek author 17 Sep 2026

fix: cipher: close embed response before getTimestamp to avoid connection starvation

devoxin maintainer 17 Sep 2026

approved
the whole thread on github.com
12/12
salina
aurum
herbarium
mysterium
parchment
whispergrove
M-x 0/0

keybindings & navigation

M-x / Alt+x Open Emacs command runner
Shift + W Jump to writings & essays (/writings)
Shift + R Jump to research & upstream work (/research)
Shift + T Choose colour theme (au-themes-select)
j / k Scroll down / up
g g Scroll to the top of page
Shift + G Scroll to the bottom of page
? Toggle this keybindings help cheat sheet
Esc / C-g Dismiss modal or close active menu