MenuDocs / erela.js

An easy-to-use Lavalink client for NodeJS.
Apache License 2.0
193 stars 80 forks source link

petitio causing a lot of errors #189

Closed YoYo178 closed 2 years ago

YoYo178 commented 2 years ago

Hello, so I use erela.js with Lavalink for my discord bot and I receive a lot of errors from petitio and it even crashes my bot everytime.

Node.js version : v16.16.0 erela.js version : v2.3.3 Lavalink version : v3.5-rc3

ee [HeadersTimeoutError]: Headers Timeout Error
    at Timeout.ct [as _onTimeout] (/home/runner/what/node_modules/petitio/dist/index.js:4:5697)
    at listOnTimeout (node:internal/timers:561:11)
    at processTimers (node:internal/timers:502:7) {
  code: 'UND_ERR_HEADERS_TIMEOUT'
}

this is the error I receive and it's really annoying

so is there any way to fix this?

anishshobithps commented 2 years ago

150 was merged so should be working now

Check with the latest development build Npm: npm install MenuDocs/erela.js#build Yarn: yarn add MenuDocs/erela.js#build

Note: To install the development build you would require git to be installed on your machine.

ghostdevv commented 2 years ago

The development build hasn't been updated from what I can tell edit: bad lockfile

YoYo178 commented 2 years ago

the error still persists but it's a bit different this time

HeadersTimeoutError: Headers Timeout Error
    at Timeout.onParserTimeout [as _onTimeout] (/home/runner/what/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28)
    at listOnTimeout (node:internal/timers:561:11)
    at processTimers (node:internal/timers:502:7) {
  code: 'UND_ERR_HEADERS_TIMEOUT'
}

EDIT - forgot to mention that i use Discord.JS v14.1.1 EDIT 2 - and as it turns out it doesn't really crash my bot but it's still annoying as it keeps spamming in the console in a regular interval EDIT 3 - uh it does crash my bot actually

realpukhraj commented 2 years ago

Same issue with me DJs v13


0|main     | SyntaxError: Unexpected token  in JSON at position 0
0|main     |     at JSON.parse ()
0|main     |     at Y.json (/home/ubuntu/bot/node_modules/petitio/dist/index.js:30:574)
0|main     |     at ke.json (/home/ubuntu/bot/node_modules/petitio/dist/index.js:30:2499)
0|main     |     at runMicrotasks ()
0|main     |     at processTicksAndRejections (node:internal/process/task_queues:96:5)```
YoYo178 commented 2 years ago

Same issue with me DJs v13

0|main     | SyntaxError: Unexpected token  in JSON at position 0
0|main     |     at JSON.parse ()
0|main     |     at Y.json (/home/ubuntu/bot/node_modules/petitio/dist/index.js:30:574)
0|main     |     at ke.json (/home/ubuntu/bot/node_modules/petitio/dist/index.js:30:2499)
0|main     |     at runMicrotasks ()
0|main     |     at processTicksAndRejections (node:internal/process/task_queues:96:5)```

yeah i also get this error sometimes, mostly when i use a Node.js version which is above 16 here's the full error :

undefined:1
<!DOCTYPE html>
^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Y.json (/home/runner/what/node_modules/petitio/dist/index.js:30:574)
    at ke.json (/home/runner/what/node_modules/petitio/dist/index.js:30:2499)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
realpukhraj commented 2 years ago

What if you use old version of nodejs

YoYo178 commented 2 years ago

What if you use old version of nodejs

it still shows up but it's less frequent

realpukhraj commented 2 years ago

In my case this is showing for every song request.

birongliu commented 2 years ago

Update to dev branch of erelajs

YoYo178 commented 2 years ago

150 was merged so should be working now

Check with the latest development build Npm: npm install MenuDocs/erela.js#build Yarn: yarn add MenuDocs/erela.js#build

Note: To install the development build you would require git to be installed on your machine.

install development build via this method right?

tried already.

dev build gives this error

HeadersTimeoutError: Headers Timeout Error
    at Timeout.onParserTimeout [as _onTimeout] (/home/runner/what/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28)
    at listOnTimeout (node:internal/timers:561:11)
    at processTimers (node:internal/timers:502:7) {
  code: 'UND_ERR_HEADERS_TIMEOUT'
}
YoYo178 commented 2 years ago

In my case this is showing for every song request.

that mostly happened to me when i used Node.js v18

realpukhraj commented 2 years ago

Oh I will move in shoukaku now so np for me

YoYo178 commented 2 years ago

Oh I will move in shoukaku now so np for me

what Java version do you use?

realpukhraj commented 2 years ago

18

YoYo178 commented 2 years ago

18

I use Java 16, try using Java 16

realpukhraj commented 2 years ago

umm, I fixed like am changed the node and java versions for root and now it is working. But the thing is that my migration from erela to shoukaku is almost done. And shoukaku can also support v18 of node and java v18 so yeah as soon as possible migrate your bot also in shoukaku cause on the new and latest version ram and CPU usages is low.

viztea commented 2 years ago

This is just an issue with your node, discord.js v14 uses undici and I doubt they would use a broken HTTP library. Shoukaku probably uses node-fetch or something that uses node's http builtin module, which probably has forgiving timeouts

YoYo178 commented 2 years ago

This is just an issue with your node, discord.js v14 uses undici and I doubt they would use a broken HTTP library. Shoukaku probably uses node-fetch or something that uses node's http builtin module, which probably has forgiving timeouts

nah it's with erela.js

becuase before i updated to the development build of erela.js, i was getting errors about petitio, and after updating to the development build i started getting errors about undici

EDIT - here's the error, it even says that it's from erela.js

HeadersTimeoutError: Headers Timeout Error
    at Timeout.onParserTimeout [as _onTimeout] (/home/runner/what/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28)
    at listOnTimeout (node:internal/timers:561:11)
    at processTimers (node:internal/timers:502:7) {
  code: 'UND_ERR_HEADERS_TIMEOUT'
}
birongliu commented 2 years ago

This is just an issue with your node, discord.js v14 uses undici and I doubt they would use a broken HTTP library. Shoukaku probably uses node-fetch or something that uses node's http builtin module, which probably has forgiving timeouts

nah it's with erela.js

becuase before i updated to the development build of erela.js, i was getting errors about petitio, and after updating to the development build i started getting errors about undici

EDIT - here's the error, it even says that it's from erela.js


HeadersTimeoutError: Headers Timeout Error

    at Timeout.onParserTimeout [as _onTimeout] (/home/runner/what/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28)

    at listOnTimeout (node:internal/timers:561:11)

    at processTimers (node:internal/timers:502:7) {

  code: 'UND_ERR_HEADERS_TIMEOUT'

}

If you look closely it actually from undici. "/home/runner/what/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28"

viztea commented 2 years ago

becuase before i updated to the development build of erela.js, i was getting errors about petitio, and after updating to the development build i started getting errors about undici

petitio uses undici...

YoYo178 commented 2 years ago

This is just an issue with your node, discord.js v14 uses undici and I doubt they would use a broken HTTP library. Shoukaku probably uses node-fetch or something that uses node's http builtin module, which probably has forgiving timeouts

nah it's with erela.js

becuase before i updated to the development build of erela.js, i was getting errors about petitio, and after updating to the development build i started getting errors about undici

EDIT - here's the error, it even says that it's from erela.js


HeadersTimeoutError: Headers Timeout Error

    at Timeout.onParserTimeout [as _onTimeout] (/home/runner/what/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28)

    at listOnTimeout (node:internal/timers:561:11)

    at processTimers (node:internal/timers:502:7) {

  code: 'UND_ERR_HEADERS_TIMEOUT'

}

If you look closely it actually from undici. "/home/runner/what/node_modules/erela.js/node_modules/undici/lib/client.js:1005:28"

yeah that's from the development build

YoYo178 commented 2 years ago

becuase before i updated to the development build of erela.js, i was getting errors about petitio, and after updating to the development build i started getting errors about undici

petitio uses undici...

well dunno about that though

Abadima commented 2 years ago

<rejected> RangeError: Plugin at index 0 does not extend Plugin.

plugins: [
    new AppleMusic(),
    new Spotify({
    clientID,
    clientSecret
    })
]

my current plugins, I use better-erela.js-spotify and better-erela.js-apple

it fixed itself when I removed

                if (!(plugin instanceof Utils_1.Plugin))
                    throw new RangeError(`Plugin at index ${index} does not extend Plugin.`);

From the dist/structures/Manager.js on line 78

viztea commented 2 years ago

I just pushed 524b5386f3102bc85ae740444b5c8c5d7258f3d6, try increasing the default headers timeout to a minute or something:

client.manager = new Manager({
  nodes: [{
    poolOptions: { 
      ...
      headersTimeout: 60e3
    }
  }]
  ...
})

Make sure to rerun the command for installing the build branch

YoYo178 commented 2 years ago

finally that fixed the issue, thank you for your time and effort.