different-ai/openwork · error · Error
Failed to load connection details (${response.status}).
Error message
Failed to load connection details (${response.status}). What it means
loadConnectionDetails in the background-agents screen POSTs to fetch worker connection details (including an expiring OpenWork URL) with a 12s timeout. If response.ok is false, this error is thrown with the server message or the status fallback. It means the worker/connections endpoint rejected the request.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/background-agents-screen.tsx:321
runtimeConfig,
} = useDenFlow();
async function loadConnectionDetails(workerId: string, workerName: string) {
setConnectBusyWorkerId(workerId);
setConnectError(null);
try {
const { response, payload } = await requestJson(
`/v1/workers/${encodeURIComponent(workerId)}/tokens`,
{
method: "POST",
body: JSON.stringify({ includeExpiringOpenworkUrl: true }),
},
12000,
);
if (!response.ok) {
throw new Error(
getErrorMessage(payload, `Failed to load connection details (${response.status}).`),
);
}
const tokens = getWorkerTokens(payload);
if (!tokens) {
throw new Error("Connection details were missing from the worker response.");
}
const nextDetails: ConnectionDetails = {
openworkUrl: tokens.openworkUrl,
ownerToken: tokens.ownerToken,
clientToken: tokens.clientToken,
openworkAppConnectUrl: buildOpenworkAppConnectUrl(
runtimeConfig.openworkAppConnectUrl,
tokens.previewOpenworkUrl,
tokens.clientToken,
workerId,View on GitHub (pinned to 2b7df46e8a)
Solutions
- Check the status code: 401 → sign in again; 403 → request background-agent permissions; 404 → verify server supports workers and the sandbox exists.
- Retry after the sandbox finishes provisioning (the toggle flow usually waits for state).
- Confirm the Den server version includes worker connection endpoints.
- Increase the timeout or check server latency if 5xx/timeouts recur.
Example fix
// before
if (!response.ok) {
throw new Error(getErrorMessage(payload, `Failed to load connection details (${response.status}).`));
}
// after
if (response.status === 404) {
throw new Error("Worker not provisioned yet — start the sandbox first.");
}
if (!response.ok) {
throw new Error(getErrorMessage(payload, `Failed to load connection details (${response.status}).`));
} Defensive patterns
Strategy: retry
Validate before calling
// Ensure session is valid before loading details
const me = await fetch("/v1/me", { method: "GET" });
if (me.status === 401) { redirectToSignIn(); } Type guard
function isConnectionDetails(v: unknown): v is { openworkUrl: string; ownerToken: string; clientToken: string } {
const t = v as Record<string, unknown> | null;
return !!t && typeof t.openworkUrl === "string" && typeof t.ownerToken === "string" && typeof t.clientToken === "string";
} Try / catch
try {
await loadConnectionDetails();
} catch (err) {
const m = err instanceof Error ? err.message : "";
if (m.includes("(404)")) showToast("Sandbox not ready — try again shortly.");
else if (m.includes("(401)")) redirectToSignIn();
else showToast(m || "Failed to load connection details");
} Prevention
- Wait for sandbox provisioning to complete before requesting connection details.
- Add retry with backoff for transient 5xx and timeouts (12s budget is tight).
- Verify the Den server supports worker endpoints before showing the toggle.
- Keep the expiring-URL request flag in sync with server capability.
When it happens
Trigger: The connection-details endpoint returns 401 (expired session), 403 (no access to the worker/sandbox), 404 (worker not provisioned or feature absent on this server), or 5xx; the 12-second timeout elapses producing a non-ok path.
Common situations: Sandbox not yet provisioned when the user toggles it on; user lacks org permissions for background agents; self-hosted Den server lacking the worker endpoints; slow backend exceeding the 12s timeout.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Automation request failed (${result.response.status}).
- Billing lookup failed (${response.status}).
- Failed to start OAuth (${response.status}).
- CUA API error ${response.status}: ${errorText.slice(0, 300)}
- latest-mac.yml is missing artifact path/url.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/e7581c5935fb3e34.
Report an issue: GitHub.