Heirless Lion
Heirless Lion11mo ago

Internal: Result of job is invalid json (empty)

Hey, I'm getting the following error while trying to execute a simple Bun script (sending a Slack message):
Unexpected error during job execution:
Object {
"message": String("Internal: Result of job is invalid json (empty)"),
"name": String("InternalErr"),
}
Unexpected error during job execution:
Object {
"message": String("Internal: Result of job is invalid json (empty)"),
"name": String("InternalErr"),
}
The code I'm trying to run looks like this:
import { WebClient } from "@slack/web-api";

type Slack = {
token: string;
};

export async function main(
slack: Slack,
channel: string,
message: string,
) {
const web = new WebClient(slack.token);
await web.chat.postMessage({
channel,
text: message,
});
return { channel, message };
}
import { WebClient } from "@slack/web-api";

type Slack = {
token: string;
};

export async function main(
slack: Slack,
channel: string,
message: string,
) {
const web = new WebClient(slack.token);
await web.chat.postMessage({
channel,
text: message,
});
return { channel, message };
}
The code executes seamlessly when I remove web.chat.PostMessage. Wrapping the entire script with a try/catch does not seem to work either - nothing gets caught. Any ideas what might be going on here?
2 Replies
Heirless Lion
Heirless Lion11mo ago
Update: when I switched to Deno (and updated the import) the run succeeded. It looks like it must be something with Bun+Slack then. Are there any additional lower-level logs I could access to debug this further? The ones in the UI contain only the few lines I pasted above. Update 2: I've just noticed another Bun jobs dying with exactly the same error. Also, did a few more tests. A new job works fine unless it contains an await inside. It almost looks like Windmill workers have trouble processing jobs that return a Bun's Promise<T> instead of simple synchronous T.
rubenf
rubenf11mo ago
@Heirless Lion could you a share a reproduction with us please I can reproduce, thanks for the script above, will investigate today unfortunately it's a bun issue, if you run:
import { WebClient } from "@slack/web-api";

type Slack = {
token: string;
};

export async function main(token: string, channel: string, message: string) {
const web = new WebClient(token);
await web.chat.postMessage({
channel,
text: message,
});
return 2;
}

let r = await main(
"<TOKEN>",
"error-handler",
"test"
);
console.log(r);
import { WebClient } from "@slack/web-api";

type Slack = {
token: string;
};

export async function main(token: string, channel: string, message: string) {
const web = new WebClient(token);
await web.chat.postMessage({
channel,
text: message,
});
return 2;
}

let r = await main(
"<TOKEN>",
"error-handler",
"test"
);
console.log(r);
with bun run locally it will hang forever