Comments (5)
I've put some relevant extracts from the bot codebase in a gist here:
https://gist.github.com/mortenn/2114a16c9fbfbed34ef510d0b2792914
from plugapi.
Could this possibly be related to plug returning a 429 response code if the client sends too many api requests in a short interval?
from plugapi.
I rewrote the bot code a bit, and made it rerun the PlugAPI call if the callback was not executed within 2 seconds, and this is what I got:
GODJ Playlist already loaded +0 482
[WARN] 06-12-18 01:38:26 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:28 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:30 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:32 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:34 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:36 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:38 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:40 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:42 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:44 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:46 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:48 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:50 PlugAPI call timed out, retrying..
[WARN] 06-12-18 01:38:52 PlugAPI call timed out, retrying..
GODJ media fetch: [] +28142 28624
GODJ Playlist contains 0 items +0 28624
GODJ Adding song to playlist: Cowboy Bebop Session XX - Recover the Sky of Day (Sora wo Torimodoshita Hi) +1 28625
[WARN] 06-12-18 01:38:55 PlugAPI call timed out, retrying..
GODJ Media added +2174 30799
For reference, this is my current iteration of the toPromise
function I am using:
function toPromise(call, autoretry)
{
let resolved = false;
return new Promise(
(resolve, reject) =>
{
var caller = () =>
{
let retry = null;
if(autoretry)
{
let doRetry = () =>
{
logger.data('WARN', 'PlugAPI call timed out, retrying..');
caller();
};
retry = setTimeout(doRetry, 2000);
}
call((err, data) =>
{
if(retry) clearTimeout(retry);
if(resolved) return;
resolved = true;
if(err)
{
logger.data('ERR', 'PlugAPI: ' + err);
reject(err);
}
else
resolve(data)
});
};
caller();
}
);
}
Which is then used like so:
function joinBooth()
{
if(amDJ() || amWaitlisted()) return Promise.reject('Redundant enqueue');
logger.debug('GODJ', 'Ready to join');
return toPromise(bot.joinBooth, true);
}
And the top level execution flow is defined like this:
new Promise(
(resolve, reject) => clearPlaylist(playlist)
.then(() => addMedia(playlist, createMedia(song)), reject)
.then(joinBooth, reject)
.then(resolve, reject)
);
The first sequence of retries is due to
toPromise((callback) => bot.getPlaylistMedias(playlist.id, callback), true)
The last one is due to
toPromise((callback) => bot.addSongToPlaylist(playlist.id, media, callback), true)
from plugapi.
This seems to be 100% reproducible on startup, but after the bot has been running a while, it is rarer.
from plugapi.
For some reason I'm unable to retrieve any data for getPlaylist() or getPlaylistMedias(), bot return "undefined" while getPlaylists() returns everything just fine. Not sure if this issue is related to what you mentioned above? Edit: seems to be the same undefined for getActivePlaylist()...
Example: console.log("PLAYLIST MEDIA", bot.getPlaylists(), bot.getPlaylist(11630973), bot.getPlaylistMedias(11630973))
returns: PLAYLIST MEDIA [ { active: true, count: 4, id: 11630973, name: 'Test' } ] undefined undefined
from plugapi.
Related Issues (20)
- Errors in callback functions passed to playlist methods are mishandled HOT 2
- Should treat URLs as atoms when splitting long chat messages HOT 5
- Use ES6 Promise in place of callbacks HOT 5
- The advance event when last DJ finishes has djs.length == 2 HOT 2
- getPlaylists callback argument is not a RESTCallback HOT 6
- Chat events mentions are always [] HOT 3
- Duplicate advance event on skip (some times) HOT 2
- Cannot read property 'length' of undefined HOT 3
- Bot gets 403 error, restarts at random intervals HOT 7
- addToWaitList throws 403 error when target user has no playlists HOT 3
- Errors trying to perform npm install plugapi HOT 2
- Error after connection with account without playlist HOT 2
- Not sure if playlist functions are working properly
- Unsupported events
- User.language is null HOT 2
- Room Description HOT 8
- Convert name to ID? HOT 8
- Have a bot.
- I'm using your api for a plug bot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugapi.