Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: screenshot, pdf and annotate still burn the full 30s timeout on an undiagnosed error when a JS dialog blocks the tab — the visual-export prelude has no dialog guard (PIN-221)

Luigi Agosti1ac075dbff32
diff --git a/internal/handlers/dialog_blocked_test.go b/internal/handlers/dialog_blocked_test.go
index 4a923b74..ed2157b5 100644
--- a/internal/handlers/dialog_blocked_test.go
+++ b/internal/handlers/dialog_blocked_test.go
@@ -80,6 +80,17 @@ func TestDialogBlockedIsTheSameContractOnReadsAndActions(t *testing.T) {
body := bytes.NewReader([]byte(`{"kind":"click","tabId":"tab1","nodeId":42}`))
h.HandleAction(w, httptest.NewRequest("POST", "/action", body))
}},
+ // The visual exports ride resolveBinaryReadContext, the sibling prelude —
+ // these rows are what stop the two preludes diverging on the guard again.
+ {"screenshot", func(h *Handlers, w *httptest.ResponseRecorder) {
+ h.HandleScreenshot(w, httptest.NewRequest("GET", "/screenshot?tabId=tab1", nil))
+ }},
+ {"pdf", func(h *Handlers, w *httptest.ResponseRecorder) {
+ h.HandlePDF(w, httptest.NewRequest("GET", "/pdf?tabId=tab1", nil))
+ }},
+ {"annotate", func(h *Handlers, w *httptest.ResponseRecorder) {
+ h.HandleAnnotate(w, httptest.NewRequest("GET", "/annotate?tabId=tab1", nil))
+ }},
}
for _, dialog := range dialogs {
@@ -116,12 +127,32 @@ func TestBusyTabWithAPendingDialogIsDialogBlockedNotUnresponsive(t *testing.T) {
}
func TestReadsAreNotDialogBlockedWithoutAPendingDialog(t *testing.T) {
- mb := &mockBridge{}
- h := New(mb, &config.RuntimeConfig{ActionTimeout: time.Second}, nil, nil, nil)
+ for _, path := range []struct {
+ name string
+ call func(h *Handlers, w *httptest.ResponseRecorder)
+ }{
+ {"url", func(h *Handlers, w *httptest.ResponseRecorder) {
+ h.HandleURL(w, httptest.NewRequest("GET", "/url?tabId=tab1", nil))
+ }},
+ {"screenshot", func(h *Handlers, w *httptest.ResponseRecorder) {
+ h.HandleScreenshot(w, httptest.NewRequest("GET", "/screenshot?tabId=tab1", nil))
+ }},
+ {"pdf", func(h *Handlers, w *httptest.ResponseRecorder) {
+ h.HandlePDF(w, httptest.NewRequest("GET", "/pdf?tabId=tab1", nil))
+ }},
+ {"annotate", func(h *Handlers, w *httptest.ResponseRecorder) {
+ h.HandleAnnotate(w, httptest.NewRequest("GET", "/annotate?tabId=tab1", nil))
+ }},
+ } {
+ t.Run(path.name, func(t *testing.T) {
+ mb := &mockBridge{}
+ h := New(mb, &config.RuntimeConfig{ActionTimeout: time.Second}, nil, nil, nil)
- w := httptest.NewRecorder()
- h.HandleURL(w, httptest.NewRequest("GET", "/url?tabId=tab1", nil))
- if w.Code == http.StatusConflict {
- t.Fatalf("read refused as dialog-blocked with no dialog pending: %s", w.Body.String())
+ w := httptest.NewRecorder()
+ path.call(h, w)
+ if w.Code == http.StatusConflict {
+ t.Fatalf("refused as dialog-blocked with no dialog pending: %s", w.Body.String())
+ }
+ })
}
}
diff --git a/internal/handlers/read_prelude.go b/internal/handlers/read_prelude.go
index 6d3bc5cf..578b9aea 100644
--- a/internal/handlers/read_prelude.go
+++ b/internal/handlers/read_prelude.go
@@ -72,6 +72,9 @@ func (h *Handlers) resolveBinaryReadContext(w http.ResponseWriter, r *http.Reque
WriteTabContextError(w, err, 404)
return "", nil, nil, false
}
+ if h.refuseIfDialogBlocked(w, resolvedTabID) {
+ return "", nil, nil, false
+ }
if _, ok := h.enforceCurrentTabDomainPolicy(w, r, ctx, resolvedTabID); !ok {
return "", nil, nil, false
}