Please describe the problem you are having in as much detail as possible:
When creating a new child process with child_process_fork() - StreamDispatcher's don't seem to be emitting the "finish" event.
What I am currently doing is making a new process, which instantiates a new Discord Client, and playing audio through it. This works fine. However, when the dispatcher is done, it doesn't emit the "end" event, and the property "ended" is false. This works fine outside of a forked process, however.
Include a reproducible code sample here, if possible:
const ytdl = require('ytdl-core');
const { Client } = require('discord.js');
const { botToken } = require('../config.json');
const client = new Client();
client.login(botToken);
let dispatcher = null;
process.on('message', async message => {
if (message.command === 'play') {
client.channels.get(message.channel).join().then(connection => {
dispatcher = connection.play(ytdl(message.link, { filter: 'audioonly' }), { volume: 0.5 });
console.log(dispatcher);
dispatcher.on('finish', () => console.log('end'));
});
}
if (message.command === 'dispatcher') {
console.log(dispatcher);
}
if (message.command === 'eval') {
eval(message.code);
}
});
Further details:
I spoke to the people in TCD (the coding den) and they seemed to point the finger towards you guys. I am pretty sure it's not a d.js issue, it's something odd inside node, but they insist it is something to do with your StreamDispatcher class.
Could you try the master branch instead of the krypton branch?
Sure can do! Give me a few minutes. Double checking it does work inside a non child process.
Ah. I was incorrect - it seems the Krypton branch is not emmitting the "finish" event. I'll try the master branch now.
Master branch seems to work fine. This appears to be a Krypton only issue.
How strange, I'll have a look into this! Thanks for reporting the issue.
No problem! Thanks for getting back so quick. If you could inform me of any updates - that'd be swell. Thanks again!
Krypton is getting a complete rewrite which will then require a rewrite of the StreamDispatcher. This should (hopefully) not be an issue when that happens.
Any update on this? Was really looking forward to using Krypton.
Once Krypton has been rewritten we should be able to reimplement it in Discord.js
This branch is no longer active as krypton will be implemented differently, so I'm closing this issue.
Most helpful comment
No problem! Thanks for getting back so quick. If you could inform me of any updates - that'd be swell. Thanks again!