Skip to content

Simplify browser routing example#95

Merged
rgarcia merged 4 commits intonextfrom
hypeship/clean-browser-routing-example
Apr 27, 2026
Merged

Simplify browser routing example#95
rgarcia merged 4 commits intonextfrom
hypeship/clean-browser-routing-example

Conversation

@rgarcia
Copy link
Copy Markdown
Contributor

@rgarcia rgarcia commented Apr 27, 2026

Summary

  • Drop typing casts and unused intermediate variables in examples/browser_routing.py
  • Remove the streaming and try/finally blocks so it mirrors the node SDK's browser-routing example
  • Verified the cleaned example runs end-to-end against production (status 200)

Test plan

  • python examples/browser_routing.py prints status 200

Note

Low Risk
Low risk: changes are limited to an example script and only adjust how it demonstrates browser request APIs and cleanup behavior.

Overview
Simplifies examples/browser_routing.py to be a minimal browser-routing demo: removes typing casts, intermediate variables, and the with/try/finally streaming pattern.

The example now shows two request styles—browsers.request (raw httpx.Response) and browsers.curl (buffered JSON envelope)—and performs explicit session cleanup via delete_by_id.

Reviewed by Cursor Bugbot for commit 84cb2e3. Bugbot is set up for automated code reviews on this repo. Configure here.

rgarcia and others added 4 commits April 27, 2026 22:51
Drop typing casts and unused streaming/cleanup blocks to mirror the
node SDK's browser-routing example.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Make it explicit that browsers.request returns a familiar httpx.Response
so users can rely on the standard interface.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add the buffered client.browsers.curl call alongside the raw streaming
client.browsers.request call, with comments noting when to use each.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rgarcia rgarcia marked this pull request as ready for review April 27, 2026 23:00
@firetiger-agent
Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: Changes are limited to example code in examples/browser_routing.py, not to kernel API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal).

To monitor this PR anyway, reply with @firetiger monitor this.

@rgarcia rgarcia merged commit 021e621 into next Apr 27, 2026
7 checks passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.

Reviewed by Cursor Bugbot for commit 84cb2e3. Configure here.

buffered = client.browsers.curl(browser.session_id, url="https://example.com", method="GET")
print("body", buffered.body)

client.browsers.delete_by_id(browser.session_id)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Browser session leaks if request or curl fails

Low Severity

The previous code wrapped the browser usage in try/finally to ensure delete_by_id was called even on failure. The new code calls client.browsers.request() and client.browsers.curl() without any error handling, so if either raises an exception, delete_by_id is never reached and the remote browser session is leaked on the server. Since this is example code that users will copy, the missing cleanup pattern could lead to orphaned browser sessions in real applications.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 84cb2e3. Configure here.

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.

1 participant