-
Notifications
You must be signed in to change notification settings - Fork 1
feat: increase watchlist item limit and prewarm installs (STR-52) #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
leo-mathurin
merged 5 commits into
staging
from
leo/str-52-increase-watchlist-item-limit
Sep 1, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
55a9d2a
feat(backend): increase watchlist limit and prewarm installs
leo-mathurin 822f5e9
fix(backend): address Greptile review feedback
leo-mathurin 39de8cf
fix(backend): coordinate prewarms across instances
leo-mathurin 157259c
fix(backend): coalesce concurrent watchlist refreshes
leo-mathurin bf4d42b
fix(app): handle degraded user flows
leo-mathurin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { Hono } from "hono"; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| const vercelMocks = vi.hoisted(() => ({ | ||
| waitUntil: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("@vercel/functions", () => vercelMocks); | ||
|
|
||
| import { scheduleBackgroundTask } from "../background"; | ||
|
|
||
| describe("scheduleBackgroundTask", () => { | ||
| const originalVercel = process.env.VERCEL; | ||
|
|
||
| beforeEach(() => { | ||
| vercelMocks.waitUntil.mockReset(); | ||
| delete process.env.VERCEL; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| if (originalVercel === undefined) { | ||
| delete process.env.VERCEL; | ||
| } else { | ||
| process.env.VERCEL = originalVercel; | ||
| } | ||
| }); | ||
|
|
||
| it("registers the task with Vercel so it can finish after the response", async () => { | ||
| process.env.VERCEL = "1"; | ||
| const task = vi.fn().mockResolvedValue(undefined); | ||
|
|
||
| scheduleBackgroundTask(task); | ||
|
|
||
| expect(vercelMocks.waitUntil).toHaveBeenCalledOnce(); | ||
| const promise = vercelMocks.waitUntil.mock.calls[0][0] as Promise<unknown>; | ||
| await promise; | ||
| expect(task).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| it("runs the task locally without registering it with Vercel", async () => { | ||
| const task = vi.fn().mockResolvedValue(undefined); | ||
|
|
||
| scheduleBackgroundTask(task); | ||
| await vi.waitFor(() => { | ||
| expect(task).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| expect(vercelMocks.waitUntil).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("does not delay the HTTP response while the task is pending", async () => { | ||
| let finishTask: (() => void) | undefined; | ||
| const pendingTask = new Promise<void>((resolve) => { | ||
| finishTask = resolve; | ||
| }); | ||
| const task = vi.fn(() => pendingTask); | ||
| const app = new Hono().get("/probe", (c) => { | ||
| scheduleBackgroundTask(task); | ||
| return c.json({ ok: true }); | ||
| }); | ||
|
|
||
| const response = await app.request("/probe"); | ||
|
|
||
| expect(response.status).toBe(200); | ||
| await expect(response.json()).resolves.toEqual({ ok: true }); | ||
| expect(task).toHaveBeenCalledOnce(); | ||
| expect(vercelMocks.waitUntil).not.toHaveBeenCalled(); | ||
|
|
||
| finishTask?.(); | ||
| await pendingTask; | ||
| }); | ||
|
|
||
| it.each([ | ||
| [ | ||
| "synchronous", | ||
| () => { | ||
| throw new Error("sync failure"); | ||
| }, | ||
| ], | ||
| ["asynchronous", () => Promise.reject(new Error("async failure"))], | ||
| ])( | ||
| "logs a %s task failure without an unhandled rejection", | ||
| async (_, task) => { | ||
| const error = vi | ||
| .spyOn(console, "error") | ||
| .mockImplementation(() => undefined); | ||
|
|
||
| scheduleBackgroundTask(task); | ||
|
|
||
| await vi.waitFor(() => { | ||
| expect(error).toHaveBeenCalledWith( | ||
| "Background task failed:", | ||
| expect.any(Error), | ||
| ); | ||
| }); | ||
| }, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { waitUntil } from "@vercel/functions"; | ||
|
|
||
| type BackgroundTask = () => Promise<unknown>; | ||
|
|
||
| export function scheduleBackgroundTask(task: BackgroundTask): void { | ||
| const promise = Promise.resolve() | ||
| .then(task) | ||
| .catch((error: unknown) => { | ||
| console.error("Background task failed:", error); | ||
| }); | ||
|
|
||
| if (process.env.VERCEL) { | ||
| waitUntil(promise); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.