fix: address Playwright API audit findings #83

Merged
steve merged 1 commits from fix/playwright-api-audit into main 2026-03-02 04:59:43 +00:00
Collaborator

Summary

Audit of all playwright-go v0.5200.0 API calls, fixing deprecated usage, resource leaks, and teardown ordering:

  • Replace deprecated Locator.Type() with PressSequentially() in node.goType() was deprecated in Playwright v1.45; PressSequentially() preserves the same key-by-key behavior
  • Fix page leak on Goto failure in playwright.goNewPage() created a page that was never closed if Goto returned an error
  • Fix teardown order in playWrightBrowser.Close() — context should close before browser (matching interactiveBrowser.Close() which already had the correct order)
  • Fix resource leak on NewPage failure in interactive.go — if initBrowser succeeded but NewPage failed, the Playwright process, browser, and context were leaked
  • Fix resource leak on context cancellation in both NewBrowser and NewInteractiveBrowser — if the Go context was cancelled mid-setup, the goroutine's browser resources were abandoned

Test plan

  • go build ./... passes
  • go vet ./... passes
  • golangci-lint run introduces zero new issues
  • go test ./... all existing tests pass

🤖 Generated with Claude Code

## Summary Audit of all `playwright-go` v0.5200.0 API calls, fixing deprecated usage, resource leaks, and teardown ordering: - **Replace deprecated `Locator.Type()`** with `PressSequentially()` in `node.go` — `Type()` was deprecated in Playwright v1.45; `PressSequentially()` preserves the same key-by-key behavior - **Fix page leak on `Goto` failure** in `playwright.go` — `NewPage()` created a page that was never closed if `Goto` returned an error - **Fix teardown order** in `playWrightBrowser.Close()` — context should close before browser (matching `interactiveBrowser.Close()` which already had the correct order) - **Fix resource leak on `NewPage` failure** in `interactive.go` — if `initBrowser` succeeded but `NewPage` failed, the Playwright process, browser, and context were leaked - **Fix resource leak on context cancellation** in both `NewBrowser` and `NewInteractiveBrowser` — if the Go context was cancelled mid-setup, the goroutine's browser resources were abandoned ## Test plan - [x] `go build ./...` passes - [x] `go vet ./...` passes - [x] `golangci-lint run` introduces zero new issues - [x] `go test ./...` all existing tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-03-02 04:54:17 +00:00
fix: address Playwright API audit findings
All checks were successful
CI / test (pull_request) Successful in 34s
CI / vet (pull_request) Successful in 48s
CI / build (pull_request) Successful in 49s
0447f1bdbe
- Replace deprecated Locator.Type() with PressSequentially() (node.go)
- Close page on Goto failure to prevent resource leak (playwright.go)
- Fix teardown order: close context before browser (playwright.go)
- Clean up resources on NewPage failure (interactive.go)
- Spawn cleanup goroutine on context cancellation in both constructors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
steve merged commit 61b68adfd0 into main 2026-03-02 04:59:43 +00:00
steve deleted branch fix/playwright-api-audit 2026-03-02 04:59:43 +00:00
Sign in to join this conversation.