Skip to content

Conversation

@agents-git-bot
Copy link
Contributor

@agents-git-bot agents-git-bot bot commented Dec 12, 2025

Synced from cloudflare/sandbox-sdk#299

Changes

Adds documentation for the new Process.waitForExit() method that allows waiting for background processes to complete and retrieving their exit codes.

Updates

  1. API Reference (api/commands.mdx):

    • Added waitForExit() to the Process methods list
    • Complete method documentation with signature, parameters, return type
    • Code examples showing basic usage and timeout handling
    • Error handling documentation
  2. Background Processes Guide (guides/background-processes.mdx):

    • New "Wait for process completion" section with practical examples
    • Examples for build processes and test runners
    • Best practice to use waitForExit() instead of arbitrary timeouts
    • Proper error handling patterns

Key Features Documented

  • Wait for process exit and get exit code
  • Optional timeout parameter
  • Exit code interpretation (0 = success, non-zero = error)
  • Proper error handling with ProcessReadyTimeoutError
  • Integration with log retrieval for debugging failures

This replaces arbitrary setTimeout() calls with a proper API for deterministic process completion checking.


Source PR: cloudflare/sandbox-sdk#299

@github-actions
Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/sandbox/ @whoiskatrin, @ghostwriternr, @cloudflare/pcx-technical-writing, @cloudflare/ai-agents

@agents-git-bot
Copy link
Contributor Author

Added comprehensive guide documentation beyond the API reference:

Additional changes:

  • Added "Wait for process completion" section in /sandbox/guides/background-processes/ with usage examples
  • Updated "Choose the right method" section in /sandbox/guides/execute-commands/ to mention startProcess() + waitForExit() as an alternative
  • Updated best practices in background-processes guide to mention waitForExit()

These guide additions help users understand when to use waitForExit() vs exec() vs long-running processes with waitForPort()/waitForLog().

🤖 Generated with Claude Code

@agents-git-bot agents-git-bot bot force-pushed the sync-docs-pr-299 branch 2 times, most recently from ce5f4a5 to 4547789 Compare December 12, 2025 14:31
Documents the new process.waitForExit() method that allows waiting
for process completion and retrieving exit codes. Includes API
reference documentation and practical examples in the background
processes guide.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Documents the new Process.waitForExit() method that allows waiting
for background processes to complete and retrieving their exit codes.

Updates:
- API reference with method signature, parameters, and examples
- Background processes guide with practical usage patterns
- Best practices to recommend waitForExit() over arbitrary timeouts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants