mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## 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).
70 lines
2.5 KiB
TypeScript
70 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { ERROR_PATTERNS } from './error-patterns'
|
|
|
|
// Representative sample messages for each error class.
|
|
// Keep this in sync when adding new patterns — the test will fail if you don't.
|
|
const PATTERN_SAMPLES: Record<string, { matches: string[]; nonMatches: string[] }> = {
|
|
ConnectionTimeoutError: {
|
|
matches: [
|
|
'CONNECTION TERMINATED DUE TO CONNECTION TIMEOUT',
|
|
'connection terminated due to connection timeout',
|
|
'ERROR: FAILED TO RUN SQL QUERY: CONNECTION TERMINATED DUE TO CONNECTION TIMEOUT.',
|
|
'Connection Terminated Due To Connection Timeout', // extra whitespace
|
|
],
|
|
nonMatches: [
|
|
'connection timeout',
|
|
'connection terminated',
|
|
'query timed out',
|
|
'idle connection timeout',
|
|
'',
|
|
],
|
|
},
|
|
SupavisorSessionPoolError: {
|
|
matches: [
|
|
'MaxClientsInSessionMode: max clients reached - in Session mode max clients are limited to pool_size',
|
|
'ERROR: MaxClientsInSessionMode: max clients reached - in Session mode max clients are limited to pool_size: 15',
|
|
],
|
|
nonMatches: ['Max client connections reached', 'max clients reached in transaction mode', ''],
|
|
},
|
|
}
|
|
|
|
describe('ERROR_PATTERNS registry', () => {
|
|
it('has a PATTERN_SAMPLES entry for every registered pattern (keep samples in sync)', () => {
|
|
for (const { ErrorClass } of ERROR_PATTERNS) {
|
|
expect(
|
|
PATTERN_SAMPLES,
|
|
`Add a PATTERN_SAMPLES entry for '${ErrorClass.name}'`
|
|
).toHaveProperty(ErrorClass.name)
|
|
}
|
|
})
|
|
|
|
describe('per-pattern match correctness', () => {
|
|
for (const { ErrorClass, pattern } of ERROR_PATTERNS) {
|
|
const samples = PATTERN_SAMPLES[ErrorClass.name]
|
|
if (!samples) continue
|
|
|
|
describe(ErrorClass.name, () => {
|
|
it.each(samples.matches)('matches: %s', (msg) => {
|
|
expect(pattern.test(msg)).toBe(true)
|
|
})
|
|
|
|
it.each(samples.nonMatches)('does not match: %s', (msg) => {
|
|
expect(pattern.test(msg)).toBe(false)
|
|
})
|
|
})
|
|
}
|
|
})
|
|
|
|
describe('no message matches more than one pattern', () => {
|
|
const allSamples = Object.entries(PATTERN_SAMPLES).flatMap(([className, { matches }]) =>
|
|
matches.map((msg) => ({ msg, sourceClass: className }))
|
|
)
|
|
|
|
it.each(allSamples)('$sourceClass sample "$msg" matches exactly one pattern', ({ msg }) => {
|
|
const matched = ERROR_PATTERNS.filter(({ pattern }) => pattern.test(msg))
|
|
expect(matched.length).toBe(1)
|
|
})
|
|
})
|
|
})
|