Skip to content

fix(jsc): AsyncDisposableStack.use() with sync @@dispose fallback#27168

Open
robobun wants to merge 1 commit intomainfrom
claude/fix-async-disposable-stack-24277
Open

fix(jsc): AsyncDisposableStack.use() with sync @@dispose fallback#27168
robobun wants to merge 1 commit intomainfrom
claude/fix-async-disposable-stack-24277

Conversation

@robobun
Copy link
Collaborator

@robobun robobun commented Feb 19, 2026

Summary

Fixes #24277

Root cause

The getAsyncDisposableMethod JSC builtin function had two bugs:

  1. It checked !isCallable(method) before isUndefinedOrNull(method), causing a TypeError when @@asyncDispose was undefined instead of falling through to the undefined check
  2. It was missing the fallback to @@dispose entirely — per the TC39 spec (GetDisposeMethod with hint async-dispose), if @@asyncDispose is not present, the runtime should fall back to @@dispose and wrap it in a Promise adapter

Additionally, AsyncDisposableStackPrototype.use() was using @getDisposableStackInternalField (sync) instead of @getAsyncDisposableStackInternalField (async).

What this PR adds

A regression test that validates:

  • AsyncDisposableStack.use() with sync @@dispose falls back correctly
  • await using with sync @@dispose works correctly
  • Objects with neither @@asyncDispose nor @@dispose still throw TypeError
  • Objects with @@asyncDispose continue to work as before

WebKit dependency

This PR depends on the WebKit fix in oven-sh/WebKit#162 being merged and a new WebKit release being created with the updated commit hash in cmake/tools/SetupWebKit.cmake.

Test plan

  • Test fails with system bun (confirms the bug exists)
  • Test passes with debug build using patched local WebKit (WEBKIT_LOCAL=ON)
  • Original reproduction case from issue works correctly

🤖 Generated with Claude Code

…4277)

Add regression test for AsyncDisposableStack.use() throwing
"@@asyncDispose must be callable" when passed an object that only
has Symbol.dispose (not Symbol.asyncDispose).

The fix is in WebKit's getAsyncDisposableMethod builtin which needs to
check for undefined/null before isCallable, then fall back to @@dispose
per the TC39 spec. See oven-sh/WebKit#162.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

Warning

Rate limit exceeded

@robobun has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.


Comment @coderabbitai help to get the list of available commands and usage tips.

@robobun
Copy link
Collaborator Author

robobun commented Feb 19, 2026

Updated 10:14 AM PT - Feb 19th, 2026

❌ Your commit 99b36194 has 3 failures in Build #37597 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 27168

That installs a local version of the PR into your bun-27168 executable, so you can run:

bun-27168 --bun

@claude
Copy link
Contributor

claude bot commented Feb 19, 2026

99b36 — Looks good!

Reviewed 1 file in test/regression/issue/: Adds a regression test verifying that AsyncDisposableStack.prototype.use() correctly falls back to synchronous Symbol.dispose when Symbol.asyncDispose is not present, per the TC39 Explicit Resource Management specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"@@asyncDispose must be callable" when using Disposable in AsyncDisposableStack (bun >=1.3.0)

1 participant