#17653: fix: catch dialog accept/dismiss errors in armDialogViaPlaywright (#17499)
size: XS
Cluster:
Browser Enhancements and Fixes
## Problem
`armDialogViaPlaywright` throws unhandled promise rejections when `dialog.accept()`/`dialog.dismiss()` fails because the dialog is already gone (page navigated, dialog auto-dismissed, etc.):
```
Error: Protocol error (Page.handleJavaScriptDialog): No dialog is showing
```
The existing `.catch()` only handles `waitForEvent` timeouts, not errors thrown inside the `.then()` callback.
## Fix
Wrap `dialog.accept()`/`dialog.dismiss()` in a try-catch to gracefully handle the case where the dialog is already gone by the time the listener fires.
Fixes #17499
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes unhandled promise rejections in `armDialogViaPlaywright` when `dialog.accept()`/`dialog.dismiss()` fails because the dialog is already gone (page navigated, dialog auto-dismissed, etc.).
- Wraps `dialog.accept()`/`dialog.dismiss()` in a try-catch inside the `.then()` callback, so errors thrown after `waitForEvent` resolves are gracefully swallowed
- The existing `.catch()` at the end of the chain only caught `waitForEvent` timeouts, not errors thrown inside `.then()` — since the promise is fire-and-forget (`void`), these would surface as unhandled rejections
- Consistent with the same pattern already used in `armFileUploadViaPlaywright` for its best-effort `page.keyboard.press("Escape")` call
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it only adds defensive error handling to a fire-and-forget code path with no behavioral changes to the happy path.
- The change is a 4-line try-catch addition in a single file. It addresses a real race condition that causes unhandled promise rejections. The fix follows an existing pattern already used in the same file. No logic changes, no new code paths, no risk of regression.
- No files require special attention.
<sub>Last reviewed commit: 04b5a9a</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17518: fix(browser): catch dialog accept/dismiss errors after page navigation
by aldoeliacim · 2026-02-15
94.7%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
71.6%
#17243: fix(telegram): catch getFile network failures to prevent gateway cr...
by robbyczgw-cla · 2026-02-15
70.3%
#6686: fix: clear Playwright's default colorScheme override on CDP-connect...
by Terwox · 2026-02-01
68.6%
#17647: fix: Display error messages instead of (no output) for non-Claude m...
by MisterGuy420 · 2026-02-16
68.4%
#18907: Fix: Improve browser error messages to avoid misleading agents
by jriff · 2026-02-17
68.3%
#11880: fix: guard decodeURIComponent against malformed percent-encoding in...
by Yida-Dev · 2026-02-08
67.6%
#12656: fix: install unhandled rejection handler before async boot operations
by kiranirabatti · 2026-02-09
67.5%
#21967: Harden Slack allow-from resolution against undefined catch crash
by graysurf · 2026-02-20
67.1%
#16112: fix: add error handler to memory file watcher to prevent crashes
by MisterGuy420 · 2026-02-14
67.1%