bun
bun copied to clipboard
node incompatibility bug: @slack/web-api not resolving promise for webClient.apiCall("apps.connections.open")
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.
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");
}
})();
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.
{
"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
}
}
- then install app to your workspace and create app level token in your bot's basic information page and add a require scope
desc | img |
---|---|
basic information page | |
install to workspace | |
generate app level token | |
add scope connections:write |
|
create .env file and put app-level token into it |
SLACK_APP_TOKEN=xxx |
- run
bun run bun
. - alternatively you try check what node does by deleting
node_modules
and runningnpm i && npm run node
What is the expected behavior?
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
What do you see instead?
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]]"}
Additional information
the same code works in node v20.11.0
but not in bun.