Files
Jordi Enric c2edb29076 fix(studio): explain Supavisor session pool limits DEBUG-43 (#53930)
## Problem

When Supavisor rejects a session because its connection pool is full,
Studio shows the error without explaining how to recover.

## Fix

Show a troubleshooting step for the session-mode limit that explains how
pool size limits concurrent clients and links to the configuration
guide.

## Screenshot

The Table Editor’s troubleshooting step, rendered locally with a sample
session-pool error.

<img width="660" alt="Expanded Supavisor session pool limit guidance in
the Table Editor"
src="https://github.com/user-attachments/assets/6072eec4-e243-4d53-a40f-30fb14d21d05"
/>

## How to test

- Display a classified MaxClientsInSessionMode error in Studio and
expand its troubleshooting step. The link should open the pool size
section of the database connection management guide.
- Display a generic transaction-mode connection limit error. It should
keep its usual fallback.
- The pattern, classification and ErrorMatcher suites exercise these
paths (144 tests passed locally).

Fixes [DEBUG-43](https://linear.app/supabase/issue/DEBUG-43).
2026-11-30 16:49:05 +01:00

24 lines
929 B
TypeScript

import { ConnectionTimeoutError, SupavisorSessionPoolError } from '@/lib/errors/studio-errors'
import type { ClassifiedError, StudioErrorInput } from '@/lib/errors/studio-errors'
type ErrorConstructor = new (input: StudioErrorInput) => ClassifiedError
export interface ErrorPattern {
pattern: RegExp
ErrorClass: ErrorConstructor
}
/**
* Maps each error class to its matching regex pattern.
* Using a Map guarantees each class can only appear once — duplicates are
* impossible by construction rather than only caught by tests.
*/
const ERROR_PATTERN_MAP = new Map<ErrorConstructor, RegExp>([
[ConnectionTimeoutError, /CONNECTION\s+TERMINATED\s+DUE\s+TO\s+CONNECTION\s+TIMEOUT/i],
[SupavisorSessionPoolError, /MaxClientsInSessionMode:\s*max clients reached/i],
])
export const ERROR_PATTERNS: ErrorPattern[] = Array.from(ERROR_PATTERN_MAP.entries()).map(
([ErrorClass, pattern]) => ({ ErrorClass, pattern })
)