crycode-de / ioBroker.discord

ioBroker Discord bot integration
MIT License
6 stars 4 forks source link

TypeError: request.headers.split is not a function #61

Closed thospr closed 1 month ago

thospr commented 1 month ago

After installation and adding the bottoken the adaptor stops and restarts with following error:

2024-05-18 23:17:01.349  - info: host.iobroker instance system.adapter.discord.0 started with pid 15268
2024-05-18 23:17:02.491  - info: discord.0 (15268) starting. Version 2.3.0 in /opt/iobroker/node_modules/iobroker.discord, node: v18.20.2, js-controller: 5.0.19
2024-05-18 23:17:02.594  - error: discord.0 (15268) No or invalid token!
2024-05-18 23:17:12.536  - info: host.iobroker stopInstance system.adapter.discord.0 (force=false, process=true)
2024-05-18 23:17:12.542  - info: discord.0 (15268) Got terminate signal TERMINATE_YOURSELF
2024-05-18 23:17:12.561  - info: discord.0 (15268) terminating
2024-05-18 23:17:12.562  - info: discord.0 (15268) Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason
2024-05-18 23:17:12.579  - info: host.iobroker stopInstance system.adapter.discord.0 send kill signal
2024-05-18 23:17:13.043  - info: discord.0 (15268) terminating
2024-05-18 23:17:13.101  - info: host.iobroker instance system.adapter.discord.0 terminated with code 11 (ADAPTER_REQUESTED_TERMINATION)
2024-05-18 23:17:15.621  - info: host.iobroker instance system.adapter.discord.0 started with pid 15395
2024-05-18 23:17:16.771  - info: discord.0 (15395) starting. Version 2.3.0 in /opt/iobroker/node_modules/iobroker.discord, node: v18.20.2, js-controller: 5.0.19
2024-05-18 23:17:16.796  - info: discord.0 (15395) Authorization is enabled but no authorized users are defined!
2024-05-18 23:17:16.938  - error: discord.0 (15395) uncaught exception: request.headers.split is not a function
2024-05-18 23:17:16.938  - error: discord.0 (15395) TypeError: request.headers.split is not a function
    at setHeadersOnRequest (/opt/iobroker/node_modules/@sentry/src/integrations/undici/index.ts:312:39)
    at _onRequestCreate (/opt/iobroker/node_modules/@sentry/src/integrations/undici/index.ts:223:7)
    at Channel.publish (node:diagnostics_channel:141:9)
    at new Request (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/core/request.js:190:23)
    at Client.[dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/client.js:304:21)
    at Intercept (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/interceptor/redirect-interceptor.js:11:16)
    at Client.[Intercepted Dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/dispatcher-base.js:158:12)
    at Client.dispatch (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/dispatcher-base.js:179:40)
    at Pool.[dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/pool-base.js:143:28)
    at Pool.[Intercepted Dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/dispatcher-base.js:150:29)
2024-05-18 23:17:16.938  - error: discord.0 (15395) request.headers.split is not a function
2024-05-18 23:17:17.086  - error: host.iobroker Caught by controller[0]: TypeError: request.headers.split is not a function
2024-05-18 23:17:17.086  - error: host.iobroker Caught by controller[0]:     at setHeadersOnRequest (/opt/iobroker/node_modules/@sentry/src/integrations/undici/index.ts:312:39)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at _onRequestCreate (/opt/iobroker/node_modules/@sentry/src/integrations/undici/index.ts:223:7)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at Channel.publish (node:diagnostics_channel:141:9)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at new Request (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/core/request.js:190:23)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at Client.[dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/client.js:304:21)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at Intercept (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/interceptor/redirect-interceptor.js:11:16)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at Client.[Intercepted Dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/dispatcher-base.js:158:12)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at Client.dispatch (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/dispatcher-base.js:179:40)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at Pool.[dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/pool-base.js:143:28)
2024-05-18 23:17:17.087  - error: host.iobroker Caught by controller[0]:     at Pool.[Intercepted Dispatch] (/opt/iobroker/node_modules/@discordjs/rest/node_modules/undici/lib/dispatcher/dispatcher-base.js:150:29)
2024-05-18 23:17:17.087  - error: host.iobroker instance system.adapter.discord.0 terminated with code 1 (JS_CONTROLLER_STOPPED)
2024-05-18 23:17:17.087  - info: host.iobroker Restart adapter system.adapter.discord.0 because enabled

Versions:

crycode-de commented 1 month ago

According to the error stack trace, the issue is related to sentry (the error reporting tool used by many ioBroker adapters). Can you run npm list @sentry/node inside the ioBroker installation dir (/opt/iobroker/) and post the output?

thospr commented 1 month ago
admin@iobroker /opt/iobroker $ npm list @sentry/node
iobroker.inst@3.0.0 /opt/iobroker
+-- iobroker.js-controller@5.0.19
| `-- @iobroker/plugin-sentry@1.2.1
|   `-- @sentry/node@7.101.1
`-- iobroker.sourceanalytix@0.4.14
  `-- @sentry/node@5.30.0

admin@iobroker /opt/iobroker $
crycode-de commented 1 month ago

Your installation contains an outdated version of the @sentry/node module which might be affected by this issue.

Try to run npm update @sentry/node to update this module. After the update, it should look like this:

peter@iobroker-test:/opt/iobroker$ npm update @sentry/node

changed 6 packages in 13s

47 packages are looking for funding
  run `npm fund` for details

peter@iobroker-test:/opt/iobroker$ npm list @sentry/node
iobroker.inst@3.0.0 /opt/iobroker
`-- iobroker.js-controller@5.0.19
  `-- @iobroker/plugin-sentry@1.2.1
    `-- @sentry/node@7.116.0
thospr commented 1 month ago

Thanks, now the adapter starts without errors.