question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

playFile(): StreamDispatcher buffer overflowing

See original GitHub issue

I’ve been working on making Discord bots and learning node.js concurrently (so I apologize in advance for any lack of general node.js/javascript conventions/standards) and one of the bots I’ve made is a simple “follow user into VoiceChannel and play sound, then leave” application. On run-time, it works pretty well for 20-30 iterations of sounds, but then it begins skipping sound playback and instead generating the error: “RangeError: Source is too large”. Given the evidence, this definitely sounds like some sort of buffer overflow, and upon debugging, I traced the error to OpusScriptEngine line 18 (encode()), being called by StreamDispatcher’s _sendBuffer() function.

It is worth noting that upon each of my successful playbacks, the stream is terminated with the message “Stream is not generating quickly enough.”

I am not sure if this an issue with the library or user error, but if it is the latter, I do apologize. Here is the code I am using the call the function for refernce:

function playSound(filePath, memberToFollow)
{
    if(memberToFollow.voiceChannelID != null)
	{
		if(semaphor == 0)
		{
			memberToFollow.voiceChannel.join()
				.then(connection =>
					{
						semaphor = 1;
						console.log('Connected!');
						const dispatcher = connection.playFile('C:\\DiscordBots\\Sounds\\soundFiles\\' + filePath);

                                                dispatcher.once('end', (reason) =>
                                                {
                                                    console.log("Disconnect reason: " + reason);
                                                    memberToFollow.voiceChannel.leave();
                                                    semaphor = 0;
                                                });
					})
				.catch(console.error);
		}
	}
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
aeminocommented, Feb 19, 2017

No worries. Glad this fixed your issue, and hopefully we can release #indev-prism soon so that everyone can enjoy the fixes it brings. 😛 (@hydrabolt)

0reactions
PhantomPhirecommented, Feb 19, 2017

After installing #indev-prism, I no longer encountered the “Stream is not generating quickly enough.” status and instead all stream terminations ended with “stream.” After testing for approximately four times the length that it took to achieve the “RangeError: Source is too large” that I was getting consistently, I could not achieve the same error at all. It seems this error was resolved with the latest #indev-prism release. Apologies for my ignorance to this release, but it has resolved my issue either way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

discord.js ( bot ) Error : TypeError: connection.playFile is not a ...
You are using discord.js v12 , playFile is now play , for more info in here so doing message.member.voice.channel.join() .then(connection ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found