Skip to content

fix(extension): send offscreen heartbeat every 20 seconds - #3319

Open
Ethereal49 wants to merge 1 commit into
browserbase:mainfrom
Ethereal49:fix/service-worker-heartbeat-interval
Open

Ethereal49 wants to merge 1 commit into
browserbase:mainfrom
Ethereal49:fix/service-worker-heartbeat-interval

Conversation

@Ethereal49

Copy link
Copy Markdown

why

The offscreen heartbeat currently posts every second, producing about 60 service-worker messages per
minute while idle. Stagehand's extension requires Chrome 116, where sending a message over the
long-lived port resets Chrome's 30-second idle timer.

Fixes #3241.

what changed

  • Send the offscreen heartbeat every 20 seconds instead of every second, leaving a 10-second margin
    below Chrome's idle shutdown timeout.
  • Add fake-timer coverage for the 20-second cadence and the existing 250 ms reconnect path.
  • Add patch changesets for the extension and the TypeScript and Python SDKs that ship it.

Offscreen document creation remains serialized, and port reconnect behavior is unchanged.

test plan

  • Isolated Vitest 5.0.3 run against the changed source and test: 4/4 passed, including the
    20-second cadence and 250 ms reconnect behavior.
  • After changing the production interval, Vitest reported 4/4 passed; before the change, the new
    interval test failed with 20 messages sent at 19,999 ms instead of 1.
  • Focused TypeScript 5.9.3 compile with the extension compiler options and a Chrome runtime stub:
    passed.
  • Supplemental changeset validation and git diff --check: passed.
  • NOT_RUN: canonical pnpm Vitest, extension typecheck/build/test, oxfmt/oxlint, and the repository
    changeset script. The workspace dependency install could not complete because the local pnpm store
    lacked openai@6.48.0; the final online attempt was stopped after remaining incomplete.
  • NOT_RUN: real-Chrome 70-second idle validation with the debugger detached, cross-version Chrome
    validation, and repository CI at the time this PR was opened.

AI assistance: Codex implemented the change and ran the checks above.

Leave a 10-second margin below Chrome's 30-second idle timeout while preserving the existing port reconnect behavior.

Fixes browserbase#3241
@changeset-bot

changeset-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8edf306

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

This PR includes changesets to release 23 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-python Patch
@browserbasehq/stagehand-extension Patch
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-cursor-sdk Patch
@browserbasehq/stagehand-integrations-example-cursor-facade Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-eve-sdk Patch
@browserbasehq/stagehand-integrations-fx-sdk Patch
@browserbasehq/stagehand-integrations-mastra-sdk Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade 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

@github-actions

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Oct 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce offscreen heartbeat frequency to avoid unnecessary service-worker wakeups

1 participant