Skip to content

Conversation

@tkattkat
Copy link
Collaborator

@tkattkat tkattkat commented Dec 29, 2025

why

waitForTimeout is a nice util function to have

what changed

added waitForTimeout to page class

test plan

wrote tests, tested locally


Summary by cubic

Added Page.waitForTimeout(ms) to pause execution for a set duration.

  • New Features
    • Page.waitForTimeout(ms) returns a Promise that resolves after the given milliseconds.

Written for commit 5a1c904. Summary will update automatically on new commits.

@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2025

🦋 Changeset detected

Latest commit: 5a1c904

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 29, 2025

Greptile Summary

Added waitForTimeout utility method to the Page class, providing a cleaner API for introducing delays. The method is a simple wrapper around the common new Promise((resolve) => setTimeout(resolve, ms)) pattern used throughout the codebase. The implementation is straightforward, well-tested, and follows existing patterns in the Page class.

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • Simple utility method with clear implementation, comprehensive test coverage using fake timers, and follows existing codebase patterns
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/lib/v3/understudy/page.ts Added simple waitForTimeout helper method that wraps setTimeout in a promise, providing clean API for delays
packages/core/tests/page-wait-for-timeout.test.ts Comprehensive test coverage for waitForTimeout using fake timers to test timing behavior without actual delays
.changeset/hungry-lemons-push.md Standard changeset file documenting patch-level change for adding waitForTimeout method

Sequence Diagram

sequenceDiagram
    participant User
    participant Page
    participant Promise
    participant setTimeout

    User->>Page: waitForTimeout(ms)
    Page->>Promise: new Promise((resolve) => ...)
    Promise->>setTimeout: setTimeout(resolve, ms)
    Note over setTimeout: Wait for ms milliseconds
    setTimeout-->>Promise: resolve()
    Promise-->>Page: Promise resolves
    Page-->>User: void
Loading

@tkattkat tkattkat merged commit 3d5af07 into main Dec 29, 2025
35 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants