shouldFallBackToLogin (main/loadFailure.ts)

clawbench · desktop/src/main/loadFailure.ts · typescript · MIT
auth, Auth / Identity

Provides helpers to decide when to fallback to login on load failure and build error script.

// Source: https://github.com/clawbench-dev/clawbench | License: MIT | Copyright 2025 xulongzhe
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Pure helpers for the main window's `did-fail-load` handling.
 *
 * Extracted from `window.ts` so the decision and the injected script can be
 * tested without an Electron runtime — `window.ts` imports `electron` at module
 * scope, which a unit test cannot load.
 */

/** Chromium's ERR_ABORTED: a cancelled navigation, not an unreachable server. */
const ERR_ABORTED = -3

export interface LoadFailure {
  errorCode: number
  failedUrl: string
  /** URL of the built-in login page, so a failure OF the login page is ignored. */
  loginUrl: string
  isMainFrame: boolean
}

/**
 * Whether a failed load means "the configured server 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key