Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions frontend/app/api/backend/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { NextRequest, NextResponse } from "next/server";

export const dynamic = "force-dynamic";

const UPSTREAM_TIMEOUT_MS = 18_000;
const DEFAULT_UPSTREAM_TIMEOUT_MS = 18_000;
const HEALTH_UPSTREAM_TIMEOUT_MS = 70_000;

const ROUTE_METHODS: Array<{ pattern: RegExp; methods: Set<string> }> = [
{ pattern: /^health$/, methods: new Set(["GET"]) },
Expand Down Expand Up @@ -88,7 +89,13 @@ async function proxyRequest(request: NextRequest, context: RouteContext) {
}

const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), UPSTREAM_TIMEOUT_MS);
// A sleeping Render backend can need well over the ordinary request timeout
// before its health endpoint answers. Keep only this readiness probe alive
// long enough to wake it; normal application requests retain the tighter
// timeout after readiness has been established.
Comment on lines 91 to +95
const upstreamTimeoutMs =
path === "health" ? HEALTH_UPSTREAM_TIMEOUT_MS : DEFAULT_UPSTREAM_TIMEOUT_MS;
const timeoutId = setTimeout(() => controller.abort(), upstreamTimeoutMs);

try {
const body = ["GET", "HEAD"].includes(request.method)
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/FoodSearchPlaceholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export function FoodSearchPlaceholder() {
setError(null);
setDidSearch(true);
setSearchStatus(
"Connecting to the food service. The first search can take up to a minute while it starts."
"Connecting to the food service. After inactivity, startup can take up to 90 seconds."
);

try {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/XamanLoginPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function XamanLoginPanel() {
setError(null);
setIsLoading(true);
setLoginStatus(
"Connecting securely. On the first visit, the service can take up to a minute to start."
"Connecting securely. After inactivity, startup can take up to 90 seconds."
);

try {
Expand Down
4 changes: 2 additions & 2 deletions frontend/lib/backendRequest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const DEFAULT_BACKEND_TIMEOUT_MS = 20_000;
export const DEFAULT_BACKEND_WARMUP_TIMEOUT_MS = 65_000;
export const DEFAULT_BACKEND_WARMUP_TIMEOUT_MS = 90_000;

const BACKEND_WARMUP_ATTEMPT_TIMEOUT_MS = 12_000;
const BACKEND_WARMUP_ATTEMPT_TIMEOUT_MS = 70_000;
const BACKEND_WARMUP_RETRY_DELAY_MS = 2_000;

export class BackendRequestTimeoutError extends Error {
Expand Down