Skip to content

[BUG] time consuming tools are crashing in cloudflare workers #1186

@sapkra

Description

@sapkra

Describe the bug

Claude says:
VoltAgent's withWaitUntil sets the global ___voltagent_wait_until inside toCloudflareWorker().fetch() but cleans it up in finally as soon as the response object is returned — before streaming/tools complete. The tools then crash because the global waitUntil has been cleared.

The workaround: pass ctx.waitUntil through the context so tools can call setWaitUntil to re-register it.

Steps To Reproduce

use voltagent in a cloudflare worker with an agent that calls a tool that takes a few seconds

Expected behavior

agent doesn't crash after tool-input-available event

Packages

"@voltagent/cli": "0.1.21",
"@voltagent/core": "2.6.14",
"@voltagent/logger": "2.0.2",
"@voltagent/resumable-streams": "2.0.2",
"@voltagent/server-core": "2.1.11",
"@voltagent/server-hono": "2.0.8",
"@voltagent/serverless-hono": "2.0.9",

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions