Giter VIP home page Giter VIP logo

Comments (5)

mortenn avatar mortenn commented on August 12, 2024

I've put some relevant extracts from the bot codebase in a gist here:
https://gist.github.com/mortenn/2114a16c9fbfbed34ef510d0b2792914

from plugapi.

mortenn avatar mortenn commented on August 12, 2024

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.

mortenn avatar mortenn commented on August 12, 2024

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.

mortenn avatar mortenn commented on August 12, 2024

This seems to be 100% reproducible on startup, but after the bot has been running a while, it is rarer.

from plugapi.

srdesigns avatar srdesigns commented on August 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.