playFile(): StreamDispatcher buffer overflowing
See original GitHub issueI’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:
- Created 7 years ago
- Comments:5 (3 by maintainers)
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)
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.