oven-sh / bun

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

Attempted to assign to readonly property with external package #8302

Closed titivermeesch closed 2 weeks ago

titivermeesch commented 9 months ago

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?

  1. Start a clean Bun project
  2. Setup the following code (including installing Ably package through npm)
    import Ably from "ably";
    const ably = new Ably.Rest({ key: "key:key" });
    ably.auth.requestToken({}, (err, res) => {
    console.log(err, res);
    });

What is the expected behavior?

The code should complain about wrong authentication or correctly process the request

What do you see instead?

15:08:38.596 Ably: Auth.requestToken(): token request API call returned error; err = RequestError: Attempted to assign to readonly property.
ABLY FAILED
1122 | var Utils = tslib_1.__importStar(__webpack_require__(2));
1123 | function toString(err) {
1124 |     var result = '[' + err.constructor.name;
1125 |     if (err.message)
1126 |         result += ': ' + err.message;
1127 |     if (err.statusCode)
                   ^
error: RequestError: Attempted to assign to readonly property.

Additional information

I set up a reproduction repo here: https://github.com/titivermeesch/bun-ably-error-reproduction The script npm run run-bun fails, but when using npm run run-node it works as expected. The first one uses bun and the second one uses Node v20.11.0)

Electroid commented 9 months ago

Possibly related to #8258

jdalton commented 9 months ago

Related ably code: https://github.com/ably/ably-js/blob/3336b660407479ccec671da0601775309dc4cfd1/src/common/lib/types/errorinfo.ts#L13

Issue in Bun only having a getter: https://github.com/oven-sh/bun/issues/3150#issuecomment-1698134905 Related PR fix: https://github.com/oven-sh/bun/pull/8368

dylan-conway commented 2 weeks ago

Fixed in bun v1.1.9 with #11082