Skip to content

fix(plugin): add timeout protection to getClient() in before_prompt_build hook#749

Open
Meskjei wants to merge 1 commit intovolcengine:mainfrom
Meskjei:fix-client-timeout
Open

fix(plugin): add timeout protection to getClient() in before_prompt_build hook#749
Meskjei wants to merge 1 commit intovolcengine:mainfrom
Meskjei:fix-client-timeout

Conversation

@Meskjei
Copy link

@Meskjei Meskjei commented Mar 18, 2026

Problem

The before_prompt_build hook calls await getClient() without timeout protection. If the OpenViking client hasn't finished initializing when the hook is triggered, the agent will hang indefinitely waiting for the client Promise to resolve.

This happens because:

  1. Plugin loads and registers the before_prompt_build hook
  2. User sends a message before start() function completes OpenViking server startup
  3. Hook triggers and calls await getClient()
  4. getClient() waits for clientPromise to resolve
  5. But clientPromise only resolves after start() finishes starting the OpenViking service
  6. Deadlock: hook blocks agent → agent can't complete → start() can't finish

Solution

Wrap getClient() call with withTimeout() (5 seconds):

  • If client initializes in time, proceed normally with memory recall
  • If timeout, log warning and skip recall gracefully
  • Agent continues without blocking

Testing

Tested locally with OpenClaw + OpenViking plugin:

  • Before fix: Agent hangs on first message if OpenViking service not ready
  • After fix: Agent responds normally, recall skipped gracefully if timeout

Related Issues

…uild hook

- Import withTimeout from process-manager.js
- Wrap getClient() call with 5-second timeout to prevent indefinite blocking
- Gracefully handle timeout by logging warning and skipping recall
- Fixes issue where agent would hang if OpenViking service wasn't ready yet

Related: volcengine#673 volcengine#748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant