Skip to content

fix: prevent infinite alert loop when table tab query fails#593

Merged
datlechin merged 1 commit intomainfrom
fix/alert-loop-on-query-failure
Apr 6, 2026
Merged

fix: prevent infinite alert loop when table tab query fails#593
datlechin merged 1 commit intomainfrom
fix/alert-loop-on-query-failure

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

  • When a table tab query fails (e.g., opening pg_stat_statements_info in the extensions schema), the "Query Execution Failed" alert shows in an infinite loop — clicking OK immediately re-triggers the alert
  • Root cause: handleQueryExecutionError never set lastExecutedAt on the tab. Dismissing the NSAlert sheet posts NSWindow.didBecomeKeyNotification, which re-evaluates the lazy-load predicate. Since lastExecutedAt == nil and resultRows.isEmpty, the predicate passes and runQuery() fires again
  • Set lastExecutedAt = Date() in the error handler so the tab is marked as "already attempted"
  • Added errorMessage == nil guard to both lazy-load predicates (didBecomeKeyNotification handler and handleTabChange) as defense-in-depth

Test plan

  • Open a table that will fail (e.g., pg_stat_statements_info in extensions schema on a PostgreSQL server without shared_preload_libraries configured)
  • Verify the error alert shows once and does not reappear after clicking OK
  • Switch away from and back to the failed tab — verify no re-trigger
  • Open a normal table tab — verify it still auto-executes correctly
  • Restore tabs from persistence with a previously-failed tab — verify no loop

@datlechin datlechin merged commit 138e6cc into main Apr 6, 2026
2 checks passed
@datlechin datlechin deleted the fix/alert-loop-on-query-failure branch April 6, 2026 05:53
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