Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#1,681 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend, search

調査の方向性

packages/web/src/features/search/zoektSearcher.ts の createReposMapForChunk から始め、続いて既存の zoektSearcher.test.ts のセットアップを読みます。同じ repository_id を共有する 100 個のファイルのケースを再現し、mocked prisma.repo.findUnique の呼び出し回数を数えます。完了条件は、1 つの chunk 内の一意な repository ごとに 1 回だけ lookup が行われ、既存のストリーミングキャッシュの動作が維持されることです。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
3.9k
フォーク
374
平均マージ
21時間 18分
マージ済み PR(30日)
39

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sourcebot-dev/sourcebot のほかの issue

sourcebot-dev/sourcebot の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。