oven-sh / bun

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

[Bug] Bun process locks if `node:http` aborts #11546

Open rhuanbarreto opened 3 months ago

rhuanbarreto commented 3 months ago

What version of Bun is running?

1.1.12+43f0913c3

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

I made a repro in a separate repository (https://github.com/rhuanbarreto/bun-repro/pull/1).

But this doesn't reproduce if run in PR. Locally I could reproduce this by running the test suite 2 or 3 times:

KEYVAULT_URL=https://{yourvault}.vault.azure.net/ bun test

What is the expected behavior?

To have both suites (always passing test and always passing test 2) for keyvault to pass every time it's run.

You can make it pass always if you copy the code creating the DefaultAzureCredential to each test specifically. But in previous versions (<= v1.1.10) it always works.

Looks like this regression is due to the improvements in fetch. Looks like there's a concurrency that is triggering the abort which locks up the whole process.

What do you see instead?

I get the following error message:

rhuan@Rhuans-Laptop bun-repro % KEYVAULT_URL=https://{myvault}.vault.azure.net/ bun test
bun test v1.1.12 (43f0913c)

keyvault.test.ts:
✓ always passing test > should pass [1181.83ms]
21 |  * }
22 |  * ```
23 |  */
24 | class AbortError extends Error {
25 |     constructor(message) {
26 |         super(message);
                 ^
AbortError: The operation was aborted.
      at new AbortError (/Users/rhuan/mycode/bun-repro/node_modules/@azure/core-rest-pipeline/node_modules/@azure/abort-controller/dist/commonjs/AbortError.js:26:13)
      at /Users/rhuan/mycode/bun-repro/node_modules/@azure/core-rest-pipeline/dist/commonjs/nodeHttpClient.js:284:25
      at abort (native:1:1)
      at /Users/rhuan/mycode/bun-repro/node_modules/@azure/core-rest-pipeline/dist/commonjs/nodeHttpClient.js:135:26
✗ always passing test 2 > should pass [268.09ms]

The bun test process hangs and never finishes.

Additional information

No response

rhuanbarreto commented 3 months ago

I managed to reproduce in the PR by flooding with calls. Looks like if node:http aborts the request, it locks the bun process.

EnsPzr commented 1 month ago

Same issue