Discord.js: Dispatcher doesn't finish in voice-krypton

Created on 25 Apr 2018  Â·  10Comments  Â·  Source: discordjs/discord.js

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.

  • discord.js version: github:discordjs/discord.js#voice-krypton (commit hash cd5270c5bd156f750dbb1f387b89ece6d00c6ea2)
  • node.js version: 8.9.4
  • Operating system: Windows 10, 64bit Personal Edition
  • Priority this issue should have – please be realistic and elaborate if possible:
    Low - I really do not see many people (if any) using a separate process for a music bot. However, I would like to get some insight if anything. Thank you!
  • [ ] I found this issue while running code on a __user account__
  • [ ] I have also tested the issue on latest master, commit hash:
voice bug

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!

All 10 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  3Comments

kvn1351 picture kvn1351  Â·  3Comments

PassTheMayo picture PassTheMayo  Â·  3Comments

Acaretia picture Acaretia  Â·  3Comments

Blumlaut picture Blumlaut  Â·  3Comments