@@ -43,7 +43,10 @@ process.env.OPENAI_API_KEY = ''
4343const reportPath : string = reportSetting
4444const directory = dirname ( reportPath )
4545const 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 } )
4750const results : Array < {
4851 name : string
4952 status : 'passed' | 'failed'
@@ -52,7 +55,6 @@ const results: Array<{
5255} > = [ ]
5356const vector = JSON . stringify ( [ 1 , ...Array . from ( { length : 1535 } , ( ) => 0 ) ] )
5457let created = false
55- let searchProxy : Awaited < ReturnType < typeof createSearchProxy > > | undefined
5658const preloadPath = join ( directory , 'embedding-transport.mjs' )
5759type ProviderScenario =
5860 | 'success'
@@ -72,7 +74,6 @@ const providerRequests: Array<{
7274 status : number
7375 inputs : number
7476} > = [ ]
75- await mkdir ( directory , { recursive : true } )
7677
7778async 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