INNER CODE UNIT · JavaScript

fetchPageContent

EdgeTypE/better-deepseek · src/background/index.js:461

async function fetchPageContent(url, options = {}) {
  if (!url) throw new Error("No URL provided.");
  const safeOptions = options && typeof options === "object" ? options : {};

  // Optional hard budget (ms). Uses the same AbortController pattern as
  // mcpFetch so a hanging host (e.g. a blackholed search provider) fails
  // fast instead of stalling the caller's provider chain for minutes (#148).
  const timeoutMs =
    Number.isFinite(safeOptions.timeoutMs) && Number(safeOptions.timeoutMs) > 0
      ? Number(safeOptions.timeoutMs)
      : 0;
  const ac = timeoutMs > 0 ? new AbortController() : null;
  const timer = ac
    ? setTimeout(
      () =>
        ac.abort(
          new DOMException(`Request timed out after ${timeoutMs}ms`, "TimeoutError")
        ),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…