-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lastfm): Patch lfm library to actually implement a request timeout …
- Loading branch information
Showing
2 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
diff --git a/node_modules/lastfm-node-client/lib/ApiRequest.js b/node_modules/lastfm-node-client/lib/ApiRequest.js | ||
index ecd39d0..c8e1cc5 100644 | ||
--- a/node_modules/lastfm-node-client/lib/ApiRequest.js | ||
+++ b/node_modules/lastfm-node-client/lib/ApiRequest.js | ||
@@ -91,7 +91,7 @@ class ApiRequest { | ||
const paramsStr = querystring.stringify(paramsObj); | ||
const options = { | ||
hostname: "ws.audioscrobbler.com", | ||
- path: "/2.0" | ||
+ path: "/2.0", | ||
}; | ||
|
||
if (method === "POST") { | ||
@@ -113,7 +113,11 @@ class ApiRequest { | ||
httpResponse.on("data", chunk => data += chunk); | ||
httpResponse.on("end", () => resolve(data)); | ||
httpResponse.on("error", err => reject(err)); | ||
- }); | ||
+ }) | ||
+ // stop waiting for request if it takes longer than 3 seconds | ||
+ .setTimeout(3000, () => { | ||
+ httpRequest.destroy(new Error('ETIMEDOUT - socket hang up')); | ||
+ }); | ||
|
||
httpRequest.on("error", err => reject(err)); | ||
|
||
diff --git a/node_modules/lastfm-node-client/lib/LastFm.js b/node_modules/lastfm-node-client/lib/LastFm.js | ||
index 2393a4d..75bdf37 100644 | ||
--- a/node_modules/lastfm-node-client/lib/LastFm.js | ||
+++ b/node_modules/lastfm-node-client/lib/LastFm.js | ||
@@ -1045,7 +1045,6 @@ class LastFm { | ||
* @param {callback} [callback] | ||
* @returns {(Promise|LastFm)} | ||
*/ | ||
- | ||
trackUpdateNowPlaying(params, callback) { | ||
const apiRequest = new ApiRequest() | ||
.set(params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters