tinyhumansai/openhuman · info
OpenRouter OAuth was cancelled.
Error message
OpenRouter OAuth was cancelled.
What it means
Pre-flight cancellation check in connectOpenRouterViaOAuth: immediately after the loopback listener binds, the function inspects deps.signal?.aborted and, if the caller already aborted, cancels the listener and throws. It represents an expected control-flow exit — the user (or component teardown) cancelled the OAuth attempt before the external browser was opened.
Solutions
- Treat this as expected cancellation, not an error: catch it and show a neutral 'cancelled' state instead of an error banner or Sentry report
- Don't abort on mere unmount if the sign-in should survive navigation — abort only on explicit user cancel
- Create one AbortController per flow attempt and never reuse it after abort
- Check `signal.aborted` before even starting the flow to avoid binding then immediately tearing down the listener
Example fix
// before
useEffect(() => {
const ctrl = new AbortController();
connectOpenRouterViaOAuth({ signal: ctrl.signal }).catch(reportError);
return () => ctrl.abort();
}, []);
// after
useEffect(() => {
const ctrl = new AbortController();
connectOpenRouterViaOAuth({ signal: ctrl.signal }).catch(err => {
if (err instanceof Error && err.message.includes('cancelled')) return; // expected
reportError(err);
});
return () => ctrl.abort();
}, []); Defensive patterns
Strategy: try-catch
Validate before calling
if (signal?.aborted) {
return; // don't even bind the loopback listener
}
const key = await connectOpenRouterViaOAuth({ signal }); Try / catch
try {
const key = await connectOpenRouterViaOAuth({ signal: ctrl.signal });
} catch (err) {
if (err instanceof Error && err.message.includes('cancelled')) {
setCancelledState(); // expected control flow — no error UI, no Sentry
return;
}
throw err;
} Prevention
- Classify 'cancelled' as an expected outcome, not an error — filter it from error reporting
- Abort only on explicit user cancel, not on every unmount, if the sign-in should survive navigation
- Check signal.aborted before starting the flow to avoid binding and immediately tearing down the listener
When it happens
Trigger: An AbortController tied to the flow is aborted between calling connectOpenRouterViaOAuth and the listener binding completing — user closes the sign-in dialog instantly, the component unmounts (React StrictMode double-mount cleanup) and its effect aborts, or an overall timeout signal fires.
Common situations: React effects that create an AbortController per mount and abort on cleanup; StrictMode's mount/unmount/mount cycle in dev; a race between the user hitting Cancel and the listener binding; tests that abort the signal before awaiting.
Related errors
- composio.authorize: entries must be strings
- composio.authorize: must be a string or array
- Composio connect failed on v3
- Composio v2 connect failed
- Composio v3 connect failed
AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17).
Data as JSON: /api/errors/4119e6a278f0d36a.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/utils/openrouterOAuth.ts:131
// sibling OAuthProviderButton flow, which trusts the bound port).
parsed.hostname = 'localhost';
return parsed.toString();
}
export async function connectOpenRouterViaOAuth(deps: OpenRouterOAuthDeps = {}): Promise<string> {
const startLoopbackListener = deps.startLoopbackListener ?? startLoopbackOauthListener;
const openExternalUrl = deps.openExternalUrl ?? openUrl;
const fetchImpl = deps.fetchImpl ?? fetch;
const signal = deps.signal;
const loopback = await startLoopbackListener({ port: OPENROUTER_LOOPBACK_PORT });
if (!loopback) {
throw new Error('OpenRouter OAuth requires the desktop app. Use an API key instead.');
}
if (signal?.aborted) {
await loopback.cancel();
throw new Error('OpenRouter OAuth was cancelled.');
}
const verifier = randomVerifier();
const challenge = await createCodeChallenge(verifier);
const authUrl = new URL(OPENROUTER_AUTH_URL);
authUrl.searchParams.set('callback_url', toOpenRouterCallbackUrl(loopback.redirectUri));
authUrl.searchParams.set('code_challenge', challenge);
authUrl.searchParams.set('code_challenge_method', PKCE_METHOD);
try {
await openExternalUrl(authUrl.toString());
const callbackUrl = await Promise.race([
loopback.awaitCallback(),
new Promise<string>((_, reject) => {
if (!signal) return;
const onAbort = () => {
signal.removeEventListener('abort', onAbort);
reject(new Error('OpenRouter OAuth was cancelled.'));View on GitHub (pinned to 7491200858)