Stirling-Tools/Stirling-PDF · error · Error

Failed to process all files: ${failedFiles.join(", ")}

Error message

Failed to process all files: ${failedFiles.join(", ")}

What it means

Thrown at the end of the per-file processing loop when every file failed (failedFiles.length > 0) and none succeeded (processedFiles.length === 0). It is the all-failed aggregate — partial failures (some succeeded) are reported via onStatus instead of throwing. Each per-file failure was already captured into failedFiles and markFileError was called.

Source

Thrown at frontend/editor/src/core/hooks/tools/shared/useToolApiCalls.ts:122

            produced: responseFiles.length,
          });
        } catch (error) {
          if (axios.isCancel(error)) {
            throw new Error("Operation was cancelled", { cause: error });
          }
          console.error("[processFiles] Failed", { name: file.name, error });
          failedFiles.push(file.name);
          // mark errored file so UI can highlight
          try {
            markFileError?.(file.fileId);
          } catch (e) {
            console.debug("markFileError", e);
          }
        }
      }

      if (failedFiles.length > 0 && processedFiles.length === 0) {
        throw new Error(
          `Failed to process all files: ${failedFiles.join(", ")}`,
        );
      }

      if (failedFiles.length > 0) {
        onStatus(
          `Processed ${processedFiles.length}/${total} files. Failed: ${failedFiles.join(", ")}`,
        );
      } else {
        onStatus(
          `Successfully processed ${processedFiles.length} file${processedFiles.length === 1 ? "" : "s"}`,
        );
      }

      console.debug("[processFiles] Completed batch", {
        total,
        successes: successSourceIds.length,
        outputs: processedFiles.length,

View on GitHub (pinned to 9ef20dcab8)

Solutions

  1. Inspect the per-file console.error entries above this throw — they hold the actual HTTP errors for each file.
  2. If all files share a cause (format, size, auth), fix the shared precondition rather than retrying per file.
  3. Check backend reachability and the network panel for the common status code.
  4. For auth failures, refresh the token/session and retry the batch.

Example fix

// before
if (failedFiles.length > 0 && processedFiles.length === 0) {
  throw new Error(`Failed to process all files: ${failedFiles.join(", ")}`);
}

// after — include the common failure reason if all files errored identically
if (failedFiles.length > 0 && processedFiles.length === 0) {
  throw new Error(`Failed to process all files: ${failedFiles.join(", ")}${lastError ? ` (${lastError})` : ""}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight one file to detect a shared failure (auth, endpoint down)
try {
  await apiClient.head(endpoint); // or a tiny probe
} catch {
  // surface a shared-cause message before running the whole batch
}

Try / catch

try {
  await processFiles(...);
} catch (e) {
  if (e instanceof Error && e.message.startsWith("Failed to process all files:")) {
    toast.error(e.message);
    // inspect console.error entries for the common per-file HTTP status
  } else throw e;
}

Prevention

When it happens

Trigger: All files in a batch hit the same backend error (e.g. endpoint down, all files corrupt, all exceed size limit); a shared misconfiguration (wrong endpoint, missing auth) makes every POST fail; the backend is unreachable for the whole batch.

Common situations: Backend down/unreachable; all selected files share an unsupported property (encrypted, wrong format); auth token expired mid-session so every request 401s.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/b27bfc66129ae384. Report an issue: GitHub.