-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@slack/web-api bug, not resolving promise for web.chat.postMessage() #8310
Comments
i encountered another bug related to the same library (issue #8924). for me |
With bun, the I don't understand which part of this library kill bun. Decided to implement directly raw http call to slack API, and not use their |
@0xVinCal do you have an example of this raw http call? |
import type { ChatPostMessageResponse } from '@slack/web-api';
import axios from 'axios';
import { config } from '../../config';
/**
* Send a message to a Slack channel
*/
export async function sendSlackMessage(channel: string, text: string): Promise<ChatPostMessageResponse> {
const result = await axios.post(
`https://slack.com/api/chat.postMessage`,
{
channel: channel,
text: text,
},
{
headers: {
Authorization: `Bearer ${config.slack.apiToken}`,
Accept: 'application/json',
'Accept-Encoding': 'identity',
},
},
);
if (!result.data.ok) {
throw new Error(`Failed to send Slack message: ${result.data.error}`);
}
return result.data;
}
|
i took a look at this again. when setting |
this is now working in Bun 1.1.9! import type { ChatPostMessageResponse } from "@slack/web-api";
import axios from "axios";
/**
* Send a message to a Slack channel
*/
export async function sendSlackMessage(
channel: string,
text: string
): Promise<ChatPostMessageResponse> {
const result = await axios.post(
`https://slack.com/api/chat.postMessage`,
{
channel: channel,
text: text,
},
{
headers: {
Authorization: `Bearer ${process.env.SLACK_BOT_TOKEN}`,
Accept: "application/json",
"Accept-Encoding": "identity",
},
}
);
if (!result.data.ok) {
throw new Error(`Failed to send Slack message: ${result.data.error}`);
}
return result.data;
}
sendSlackMessage("orders", "Hello, World!").then((response) => {
console.log(response);
}); |
thanks yall |
tested my repro case and this works in bun 1.1.10 |
What version of Bun is running?
1.0.24+6fa35839c
What platform is your computer?
Darwin 23.2.0 arm64 arm
What steps can reproduce the bug?
calling the web.chat.postMessage function will not resolve a promise however the message does successfully get posted to Slack. When running this function in Node the promise resolves as expected.
What is the expected behavior?
to receive a JSON reply like so
{
ok: true,
channel: 'XXXXXX',
ts: '1705793121.715479',
message: {
bot_id: 'XXXXXX',
type: 'message',
text: 'test',
user: 'XXXXXX',
ts: '1705793121.715479',
app_id: 'XXXXXX',
blocks: [ [Object], [Object] ],
team: 'XXXXXX',
bot_profile: {
id: 'XXXXXX',
app_id: 'XXXXXX',
name: 'Test Bot',
icons: [Object],
deleted: false,
updated: 1692580490,
team_id: 'XXXXX'
}
},
response_metadata: { scopes: [ 'chat:write' ], acceptedScopes: [ 'chat:write' ] }
}
What do you see instead?
no response is received.
Additional information
No response
The text was updated successfully, but these errors were encountered: