Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

test: serialize shared-pool E2E search requests (#5353)

Ezra Elletted9299ec743af
diff --git a/apps/screenpipe-app-tauri/e2e/specs/api-search-stress.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/api-search-stress.spec.ts
index c42857892..f38c46c86 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/api-search-stress.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/api-search-stress.spec.ts
@@ -12,6 +12,14 @@ import {
waitForLocalApi,
} from "../helpers/api-utils.js";
+async function runSerially<T>(requests: Array<() => Promise<T>>): Promise<T[]> {
+ const results: T[] = [];
+ for (const request of requests) {
+ results.push(await request());
+ }
+ return results;
+}
+
describe("Local API search and stability", function () {
this.timeout(240_000);
@@ -447,12 +455,13 @@ describe("Local API search and stability", function () {
expectNoServerError(res, "public audio status");
});
- it("handles 20 concurrent authenticated search requests", async function () {
+ it("handles 20 authenticated searches within the SQLite concurrency budget", async function () {
if (!key) this.skip();
- const requests = Array.from({ length: 20 }, (_, i) =>
- authedGet(`/search?limit=1&q=concurrent-${i}`),
+ const requests = Array.from(
+ { length: 20 },
+ (_, i) => () => authedGet(`/search?limit=1&q=concurrent-${i}`),
);
- const results = await Promise.all(requests);
+ const results = await runSerially(requests);
const unexpectedErrors = results.filter(
(res) => !res.ok && !isSearchBusyResponse(res),
);
@@ -490,25 +499,38 @@ describe("Local API search and stability", function () {
it("handles mixed readonly API load while the UI stays responsive", async function () {
if (!key) this.skip();
- const endpoints = [
- "/health",
+ // Uncached searches share the SQLite read pool and its route admission
+ // budget. Keep that subgroup serial while unrelated readonly APIs still
+ // apply concurrent load and exercise UI responsiveness.
+ const sharedPoolEndpoints = [
"/search?limit=1&content_type=ocr",
"/search?limit=1&content_type=audio",
+ ];
+ const otherEndpoints = [
+ "/health",
"/audio/device/status",
"/vision/status",
"/meetings/status",
];
- const results = await Promise.all(
- Array.from({ length: 4 }, () => endpoints)
- .flat()
- .map(async (path) => ({
- path,
- response:
- path === "/health" || path === "/audio/device/status"
- ? await fetchJson(apiUrl(path))
- : await authedGet(path),
- })),
- );
+ const [otherResults, sharedPoolResults] = await Promise.all([
+ Promise.all(
+ Array.from({ length: 4 }, () => otherEndpoints)
+ .flat()
+ .map(async (path) => ({
+ path,
+ response:
+ path === "/health" || path === "/audio/device/status"
+ ? await fetchJson(apiUrl(path))
+ : await authedGet(path),
+ })),
+ ),
+ runSerially(
+ Array.from({ length: 4 }, () => sharedPoolEndpoints)
+ .flat()
+ .map((path) => async () => ({ path, response: await authedGet(path) })),
+ ),
+ ]);
+ const results = [...otherResults, ...sharedPoolResults];
const unexpectedErrors = results.filter(
({ path, response }) =>
!response.ok &&
diff --git a/apps/screenpipe-app-tauri/e2e/specs/windows-system-integration.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/windows-system-integration.spec.ts
index f6b00a34d..ef627ea7c 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/windows-system-integration.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/windows-system-integration.spec.ts
@@ -438,26 +438,41 @@ $uniqueNames = @($names | Sort-Object -Unique)
if (!isWindows || !api) this.skip();
const started = Date.now();
- const requests = [
- ...Array.from({ length: 12 }, async () => ({
- kind: "health" as const,
- response: await fetchJson(apiUrl(api!, "/health")),
- })),
- ...Array.from({ length: 8 }, (_, i) =>
- fetchJson(
- apiUrl(api!, `/search?limit=1&q=windows-load-${i}`),
- authHeaders(api!.key),
- ).then((response) => ({ kind: "search" as const, response })),
+ const runSearches = async () => {
+ const results = [];
+ // Uncached searches share the SQLite read pool. Windows CI uses a pool
+ // size whose route admission budget is one, so keep this group serial
+ // while health and vision requests continue exercising the API in parallel.
+ for (let i = 0; i < 8; i += 1) {
+ results.push({
+ kind: "search" as const,
+ response: await fetchJson(
+ apiUrl(api!, `/search?limit=1&q=windows-load-${i}`),
+ authHeaders(api!.key),
+ ),
+ });
+ }
+ return results;
+ };
+ const [healthResults, searchResults, visionResults] = await Promise.all([
+ Promise.all(
+ Array.from({ length: 12 }, async () => ({
+ kind: "health" as const,
+ response: await fetchJson(apiUrl(api!, "/health")),
+ })),
),
- ...Array.from({ length: 4 }, async () => ({
- kind: "vision" as const,
- response: await fetchJson(
- apiUrl(api!, "/vision/status"),
- authHeaders(api!.key),
- ),
- })),
- ];
- const results = await Promise.all(requests);
+ runSearches(),
+ Promise.all(
+ Array.from({ length: 4 }, async () => ({
+ kind: "vision" as const,
+ response: await fetchJson(
+ apiUrl(api!, "/vision/status"),
+ authHeaders(api!.key),
+ ),
+ })),
+ ),
+ ]);
+ const results = [...healthResults, ...searchResults, ...visionResults];
const elapsed = Date.now() - started;
expect(elapsed).toBeLessThan(t(30_000));