Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[bug] Search result hydration performs duplicate repository lookups within the same chunk

Aperta Adatta ai principianti
#1,681 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend, search

Direzione di ricerca

Inizia in packages/web/src/features/search/zoektSearcher.ts, all'interno di createReposMapForChunk, poi leggi la configurazione esistente di zoektSearcher.test.ts. Riproduci il caso con 100 file che condividono lo stesso repository_id e conta le chiamate a mocked prisma.repo.findUnique. Il lavoro è completo quando viene effettuata una sola query per ogni repository univoco all'interno di un chunk, mantenendo intatto il comportamento esistente della cache di streaming.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug triage needed
Describe the bug

When search returns multiple files from the same repository, createReposMapForChunk performs a separate Prisma repository lookup for each file.

The repository cache is checked inside concurrent Promise.all callbacks, but it is only populated after the database query resolves. Because of this, files from the same uncached repository all miss the cache and start duplicate lookups.

For example, I tested 100 search results from the same repository and observed 100 prisma.repo.findUnique calls instead of 1.

I would expect repository metadata to be fetched once per unique repository and reused for the other results.

This adds unnecessary database work to the search path, especially when many results come from the same repository.

To reproduce

Using the existing zoektSearcher.test.ts setup:

Return 100 files with the same repository_id.
Mock prisma.repo.findUnique and count the calls.
Run zoektSearch.
findUnique is called 100 times, even though all files belong to one repository.

I also tested two repositories:

100 files from 1 repository → 100 lookups
100 files split across 2 repositories → 100 lookups

For streaming search, the cache works across completed chunks. A second chunk containing files from an already cached repository makes 0 additional lookups. The duplicate lookups happen within the same chunk.

Sourcebot deployment information

Sourcebot version: Local development build from current main

Additional information

Relevant code:

packages/web/src/features/search/zoektSearcher.ts

Function:

createReposMapForChunk

The same search path is also used by Ask Sourcebot tools such as grep and glob.

I haven't measured the production latency impact, so the confirmed issue here is the redundant database work rather than a specific search latency regression.

Lingua principale
TypeScript
Stelle
3.9k
Fork
374
Merge medio
21h 18m
PR unite (30g)
39

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sourcebot-dev/sourcebot

Tutte le issue di sourcebot-dev/sourcebot

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.