Skip to content

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

@erictheswift

Description

@erictheswift

What version of Bun is running?

v1.3.0+

What platform is your computer?

Darwin 25.0.0 arm64 arm

What steps can reproduce the bug?

#!/bin/bash

# Create repro script
cat > bun-asyncdisposablestack-repro.ts << 'EOF'
await using scope = new AsyncDisposableStack()

scope.use({
  async [Symbol.asyncDispose]() {
    console.log('async dispose')
  },
})

scope.use({
  [Symbol.dispose]() {
    console.log('sync dispose')
  },
})
EOF

echo "=== Testing current Bun version ==="
bun --revision
bun ./bun-asyncdisposablestack-repro.ts

echo -e "\n=== Testing Bun v1.3.0 ==="
curl -fsSl https://bun.sh/install | bash -s "bun-v1.3.0"
bun --revision
bun ./bun-asyncdisposablestack-repro.ts

echo -e "\n=== Testing Bun v1.2.23 with polyfill ==="
curl -fsSl https://bun.sh/install | bash -s "bun-v1.2.23"
bun --revision
bun --preload disposablestack/auto ./bun-asyncdisposablestack-repro.ts

echo -e "\n=== Testing Node.js ==="
node --version
node ./bun-asyncdisposablestack-repro.ts

rm bun-asyncdisposablestack-repro.ts

What is the expected behavior?

sync dispose
async dispose

everywhere

What do you see instead?

async dispose
4 |   async [Symbol.asyncDispose]() {
5 |     console.log('async dispose')
6 |   },
7 | })
8 |
9 | scope.use({
              ^
TypeError: @@asyncDispose must be callable
      at use (1:11)
      at bun-asyncdisposablestack-repro.ts:9:7

Additional information

Polyfills do not autoapply because stacks are implemented, however AsyncDisposableStack implementation is incomplete and I see no oneliner workarounds for these versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions