Skip to content

Commit 1acb187

Browse files
committed
fix(docs): strengthen search cancellation and IPv6 checks
1 parent bcf69fa commit 1acb187

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎apps/docs/scripts/test-navigation-e2e.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,12 +1711,12 @@ try {
17111711
const requested = page.waitForRequest((request) =>
17121712
request.url().includes('query=cancel-request')
17131713
)
1714+
await page.getByRole('combobox', { name: 'Search documentation' }).fill('cancel-request')
1715+
await requested
17141716
const failed = page.waitForEvent('requestfailed', {
17151717
predicate: (request) => request.url().includes('query=cancel-request'),
1716-
timeout: 10000,
1718+
timeout: 2000,
17171719
})
1718-
await page.getByRole('combobox', { name: 'Search documentation' }).fill('cancel-request')
1719-
await requested
17201720
await page.keyboard.press('Escape')
17211721
expect((await failed).failure()?.errorText).toMatch(/abort|cancel/i)
17221722
await expect(page.getByRole('dialog')).toHaveCount(0)

‎apps/docs/scripts/test-search-postgres-e2e.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ process.env.OPENAI_API_KEY = ''
4343
const reportPath: string = reportSetting
4444
const directory = dirname(reportPath)
4545
const workspace = resolve(import.meta.dirname, '..')
46-
const sql = postgres(databaseUrl.href, { max: 1 })
46+
const databaseHost = databaseUrl.hostname.replace(/^\[|\]$/g, '')
47+
await mkdir(directory, { recursive: true })
48+
const searchProxy = chunksOnly ? undefined : await createSearchProxy()
49+
const sql = postgres(searchProxy?.url ?? databaseUrl.href, { max: 1 })
4750
const results: Array<{
4851
name: string
4952
status: 'passed' | 'failed'
@@ -52,7 +55,6 @@ const results: Array<{
5255
}> = []
5356
const vector = JSON.stringify([1, ...Array.from({ length: 1535 }, () => 0)])
5457
let created = false
55-
let searchProxy: Awaited<ReturnType<typeof createSearchProxy>> | undefined
5658
const preloadPath = join(directory, 'embedding-transport.mjs')
5759
type ProviderScenario =
5860
| 'success'
@@ -72,7 +74,6 @@ const providerRequests: Array<{
7274
status: number
7375
inputs: number
7476
}> = []
75-
await mkdir(directory, { recursive: true })
7677

7778
async function check(name: string, action: () => Promise<void>) {
7879
const started = performance.now()
@@ -95,7 +96,7 @@ async function createSearchProxy() {
9596
const buffered = new Map<Socket, Buffer[]>()
9697
let paused = false
9798
const server = createServer((client) => {
98-
const upstream = connect(Number(databaseUrl.port || 5432), databaseUrl.hostname)
99+
const upstream = connect(Number(databaseUrl.port || 5432), databaseHost)
99100
sockets.add(client)
100101
sockets.add(upstream)
101102
assert(sockets.size <= 16, 'Search proxy connection cap exceeded')
@@ -177,7 +178,7 @@ async function index(
177178
cwd: workspace,
178179
env: {
179180
...process.env,
180-
DATABASE_URL: databaseUrl.href,
181+
DATABASE_URL: searchProxy?.url ?? databaseUrl.href,
181182
OPENAI_API_KEY: useProvider ? 'isolated-fixture' : '',
182183
DOCS_SEARCH_REPORT_PATH: outputPath,
183184
},
@@ -325,8 +326,8 @@ async function verifyDatabase() {
325326
Array<{ count: number }>
326327
>`SELECT count(*)::int AS count FROM information_schema.tables WHERE table_schema = 'public'`
327328
assert(existing?.count === 0, 'Refusing to mutate a database that already contains tables')
328-
const proxy = await createSearchProxy()
329-
searchProxy = proxy
329+
const proxy = searchProxy
330+
assert(proxy, 'Search proxy fixture is required for database verification')
330331
process.env.DATABASE_URL = proxy.url
331332
await sql`CREATE EXTENSION IF NOT EXISTS vector`
332333
await sql`

0 commit comments

Comments
 (0)