Skip to content

Commit

Permalink
fix: query timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed May 2, 2024
1 parent d31cf12 commit e49ebcd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const GENERATE_TYPES_DETECT_ONE_TO_ONE_RELATIONSHIPS =

export const DEFAULT_POOL_CONFIG: PoolConfig = {
max: 1,
connectionTimeoutMillis: PG_CONN_TIMEOUT_SECS * 1000,
query_timeout: PG_CONN_TIMEOUT_SECS * 1000,
ssl: PG_META_DB_SSL_ROOT_CERT ? { ca: PG_META_DB_SSL_ROOT_CERT } : undefined,
}

Expand Down
15 changes: 15 additions & 0 deletions test/server/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test } from 'vitest'
import { app } from './utils'
import { DEFAULT_POOL_CONFIG } from '../../src/server/constants'

test('query', async () => {
const res = await app.inject({
Expand Down Expand Up @@ -539,3 +540,17 @@ test('very big number', async () => {
]
`)
})

test('query timeout', async () => {
const defaultTimeout = DEFAULT_POOL_CONFIG.query_timeout
DEFAULT_POOL_CONFIG.query_timeout = 100

const res = await app.inject({
method: 'POST',
path: '/query',
payload: { query: "select pg_sleep_for('1 minute');" },
})
expect(res.json()?.error).toMatchInlineSnapshot(`"Query read timeout"`)

DEFAULT_POOL_CONFIG.query_timeout = defaultTimeout
})

0 comments on commit e49ebcd

Please sign in to comment.