Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[fix] Passing a discord.js client through workerdata throws an error #249

Copy link
Copy link

Description

@seirdotexe
Issue body actions

Describe the bug

Node.js version: 20.14.0

OS version: Windows 11 Pro 23H2

Description: The discord.js client cannot be passed through workerData. I have to do this, because I need it in my jobs.

Actual behavior

It should pass the discord.js client so I can use it in my jobs.

Expected behavior

I receive the following error:

node:internal/per_context/domexception:53
    ErrorCaptureStackTrace(this);
    ^
DOMException [DataCloneError]: (_, shardId) => {
      for (const [guildId, adapter] of this.adapters.entries()) {
        if (client.guilds.c...<omitted>... } could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at new Worker (node:internal/worker:266:17)
    at Bree.createWorker (C:\Users\seir\Documents\GitHub\SMERSH\node_modules\bree\src\index.js:764:12)
    at Bree.run (C:\Users\seir\Documents\GitHub\SMERSH\node_modules\bree\src\index.js:384:35)
    at C:\Users\seir\Documents\GitHub\SMERSH\node_modules\bree\src\index.js:605:18
    at Timeout.fireNow (C:\Users\seir\Documents\GitHub\SMERSH\node_modules\safe-timers\index.js:36:10)
    at Timeout.fired (C:\Users\seir\Documents\GitHub\SMERSH\node_modules\safe-timers\index.js:25:11)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)

Code to reproduce

// index.js
import Bree from 'bree';
import { Client, GatewayIntentBits } from 'discord.js';

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const bree = new Bree({
  jobs: [
    {
      name: 'test',
      worker: { workerData: { client } }
    }
  ]
});

await bree.start();

// jobs/test.js
console.log('Test');

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.