oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.54k stars 2.71k forks source link

JSGlobalProxy is not a constructor #11353

Open kcoderhtml opened 4 months ago

kcoderhtml commented 4 months ago

What version of Bun is running?

1.1.10

What platform is your computer?

Linux 6.8.9-arch1-2 x86_64 unknown

What steps can reproduce the bug?

Set up a slack bot using @slack/bolt and listen for events with a set event URL and trigger an event.

import { App, LogLevel } from '@slack/bolt';

const app = new App({
    token: process.env.SLACK_BOT_TOKEN,
    signingSecret: process.env.SLACK_SIGNING_SECRET,
    appToken: process.env.SLACK_APP_TOKEN,
    logLevel: LogLevel.INFO,
    port: 3000,
});

// listen for new members joining the market - town square channels
app.event('member_joined_channel', async ({ event, client }) => {
    console.log("event triggered")
});

(async () => {
    try {
        // Start your app
        await app.start(Number(process.env.PORT) || 3000);

        console.log('⚡️ Bolt app is running!');
    } catch (error) {
        console.error(error);
    }
})();

What is the expected behavior?

Nothing would be produced because no errors should be caused

What do you see instead?

[ERROR]  bolt-app 20 |     ErrorCode["UnknownError"] = "slack_bolt_unknown_error";
21 |     ErrorCode["WorkflowStepInitializationError"] = "slack_bolt_workflow_step_initialization_error";
22 | })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
23 | class UnknownError extends Error {
24 |     constructor(original) {
25 |         super(original.message);
             ^
error: JSGlobalProxy is not a constructor
 code: "slack_bolt_unknown_error"

      at new UnknownError (/home/kierank/Documents/Projects/the-old-man/node_modules/@slack/bolt/dist/errors.js:25:9)
      at asCodedError (/home/kierank/Documents/Projects/the-old-man/node_modules/@slack/bolt/dist/errors.js:35:12)
      at handleError (/home/kierank/Documents/Projects/the-old-man/node_modules/@slack/bolt/dist/App.js:612:35)

[ERROR]   An unhandled error occurred while Bolt processed an event

Additional information

original issue: https://github.com/slackapi/bolt-js/issues/2118#issuecomment-2131128419 the reason they believed it was causing errors: https://github.com/slackapi/bolt-js/issues/2118#issuecomment-2131128419

rrogowski commented 3 months ago

Seeing the same issue with version 1.1.13 of Bun running via AWS Fargate.

sgarbesi commented 3 months ago

Same issue with Bun 1.1.15 on Mac OS 14.5

sgarbesi commented 3 months ago

This line is the issue:

Comments line 1052, 1121-1129 and you'll see it goes through. Something is broken with the allSettled Function in this library when used with Bun.

The following change works in Bun:

const settledListenerResults = await allSettled(listenerResults); const settledListenerResults = await Promise.allSettled(listenerResults);


Aside from the ticket in the issue, it also appears that line 1052 gets hung up and is unable to send a Websockets response back. This works fine in Node.js, not in Bun.

gmillerd commented 3 months ago

Same error, on bun 1.1.17 (and 1.1.21 canary), slack/bolt 3.19.0 ... I am running bolt in socket mode. As soon as any event fires, the exception occurs. Works with node and deno.

Error: JSGlobalProxy is not a constructor at new UnknownError (/home/bun/node_modules/@slack/bolt/dist/errors.js:30:9) at asCodedError (/home/bun/node_modules/@slack/bolt/dist/errors.js:40:16) at handleError (/home/bun/node_modules/@slack/bolt/dist/App.js:612:44) at processTicksAndRejections (:12:39)

Azarattum commented 2 months ago

Can confirm for bun 1.1.20 as well