Open jozan opened 7 months ago
1.0.26+c75e768a6
Darwin 23.3.0 x86_64 i386
this doesn't work in bun but works in node. this is somewhat related to #8310 as we are using the same library but the issue might be different.
import { WebClient, LogLevel } from "@slack/web-api"; const appToken = process.env.SLACK_APP_TOKEN; const webClient = new WebClient(appToken, { logLevel: LogLevel.DEBUG, }); (async () => { try { console.log("test open connection"); const r = await webClient.apiCall("apps.connections.open"); console.log("result", r); } catch (e) { console.log("error", e); } finally { console.log("test open connection finally"); } })();
most of these steps are just creating a slack bot and obtaining app-level token for it.
clone this repo: https://github.com/jozan/bun-slack-bot
run bun install
bun install
go to your slack organization settings page and create a new app. direct link (https://api.slack.com/apps?new_app=1)
select create from manifest and paste this manifest. it will create a bot that has some permissions and has socket mode enabled.
{ "display_information": { "name": "bun-test-bot", "description": "desc", "background_color": "#0d1f07" }, "features": { "bot_user": { "display_name": "bun-test-bot", "always_online": false } }, "oauth_config": { "scopes": { "bot": [ "app_mentions:read", "channels:history", "chat:write" ] } }, "settings": { "event_subscriptions": { "bot_events": [ "app_mention", "message.channels" ] }, "interactivity": { "is_enabled": true }, "org_deploy_enabled": false, "socket_mode_enabled": true, "token_rotation_enabled": false } }
connections:write
.env
SLACK_APP_TOKEN=xxx
bun run bun
node_modules
npm i && npm run node
this is what node gives us
[DEBUG] web-api:WebClient:0 initialized test open connection [DEBUG] web-api:WebClient:0 apiCall('apps.connections.open') start [DEBUG] web-api:WebClient:0 http request url: https://slack.com/api/apps.connections.open [DEBUG] web-api:WebClient:0 http request body: {} [DEBUG] web-api:WebClient:0 http request headers: {"Accept":"application/json, text/plain, */*","User-Agent":"@slack:web-api/7.0.2 node/20.11.0 darwin/23.3.0","Authorization":"[[REDACTED]]"} [DEBUG] web-api:WebClient:0 http response received [DEBUG] web-api:WebClient:0 http request result: {"ok":true,"url":"wss://wss-primary.slack.com/link/?ticket=[[REDACTED]]","response_metadata":{"scopes":["connections:write"],"acceptedScopes":["connections:write"]}} [DEBUG] web-api:WebClient:0 apiCall('apps.connections.open') end result { ok: true, url: 'wss://wss-primary.slack.com/link/?ticket=[[REDACTED]]', response_metadata: { scopes: [ 'connections:write' ], acceptedScopes: [ 'connections:write' ] } } test open connection finally
the promise never resolves:
$ bun slack.ts [DEBUG] web-api:WebClient:0 initialized test open connection [DEBUG] web-api:WebClient:0 apiCall('apps.connections.open') start [DEBUG] web-api:WebClient:0 http request url: https://slack.com/api/apps.connections.open [DEBUG] web-api:WebClient:0 http request body: {} [DEBUG] web-api:WebClient:0 http request headers: {"Accept":"application/json, text/plain, */*","User-Agent":"@slack:web-api/7.0.2 bun/21.6.0 darwin/23.3.0","Authorization":"[[REDACTED]]"}
the same code works in node v20.11.0 but not in bun.
node v20.11.0
some more info why @slack/web-api doesn't work on: https://github.com/oven-sh/bun/issues/8310#issuecomment-2075336600
@slack/web-api
in short axios maxRedirects: 0 and missing brotli compression are the culprit.
maxRedirects: 0
does this still reproduce for you? brotli support was added in Bun 1.1.8 and some http improvements made it into Bun 1.1.9.
What version of Bun is running?
1.0.26+c75e768a6
What platform is your computer?
Darwin 23.3.0 x86_64 i386
What steps can reproduce the bug?
this doesn't work in bun but works in node. this is somewhat related to #8310 as we are using the same library but the issue might be different.
repro steps
most of these steps are just creating a slack bot and obtaining app-level token for it.
clone this repo: https://github.com/jozan/bun-slack-bot
run
bun install
go to your slack organization settings page and create a new app. direct link (https://api.slack.com/apps?new_app=1)
select create from manifest and paste this manifest. it will create a bot that has some permissions and has socket mode enabled.
connections:write
.env
file and put app-level token into itSLACK_APP_TOKEN=xxx
bun run bun
.node_modules
and runningnpm i && npm run node
What is the expected behavior?
this is what node gives us
What do you see instead?
the promise never resolves:
Additional information
the same code works in
node v20.11.0
but not in bun.