docmirror/dev-sidecar · warning

下载远程 pac.txt 文件成功,但内容为空或内容太短,判断为无效的 pax.txt 文件:

Error message

下载远程 pac.txt 文件成功,但内容为空或内容太短,判断为无效的 pax.txt 文件:

What it means

The overwall plugin downloads a remote pac.txt (gfwlist-style) file to build its proxy rules. If the download succeeds with HTTP 200 but the body is null or shorter than 100 bytes, the content is judged invalid (e.g. an error page, redirect stub, or CAPTCHA body), a warning is logged, and the pac file is not updated — the previous rules remain in effect.

Source

Thrown at packages/mitmproxy/src/lib/proxy/middleware/overwall.js:101

          log.info(`'${pacFilePath}' 文件的修改时间已更新为其最近更新时间 '${dateUtil.format(lastModifiedTime, false)}'`)
        }
      })
    })
  }
}

// 异步下载 pac.txt ,避免影响代理服务的启动速度
async function downloadPacAsync (pacConfig) {
  const remotePacFileUrl = pacConfig.pacFileUpdateUrl
  log.info('开始下载远程 pac.txt 文件:', remotePacFileUrl)
  request(remotePacFileUrl, (error, response, body) => {
    if (error) {
      log.error(`下载远程 pac.txt 文件失败: ${remotePacFileUrl}, error:`, error, ', response:', response, ', body:', body)
      return
    }
    if (response && response.statusCode === 200) {
      if (body == null || body.length < 100) {
        log.warn('下载远程 pac.txt 文件成功,但内容为空或内容太短,判断为无效的 pax.txt 文件:', remotePacFileUrl, ', body:', body)
        return
      } else {
        log.info('下载远程 pac.txt 文件成功:', remotePacFileUrl)
      }

      // 尝试解析Base64(注:https://gitlab.com/gfwlist/gfwlist/raw/master/gfwlist.txt 下载下来的是Base64格式)
      let pacTxt = body
      if (!pacTxt.includes('!---------------------EOF')) {
        try {
          pacTxt = Buffer.from(pacTxt, 'base64').toString('utf8')
          // log.debug('解析 base64 后的 pax:', pacTxt)
        } catch {
          log.error(`远程 pac.txt 文件内容即不是base64格式,也不是要求的格式,url: ${remotePacFileUrl},body: ${body}`)
          return
        }
      }

      // 保存到本地

View on GitHub (pinned to 7710cd56cc)

Solutions

  1. Check remotePacFileUrl in a browser/curl — if it no longer serves the list, update the pac URL in overwall config to a valid mirror.
  2. Bypass any captive portal / complete network login, then trigger the download again.
  3. Host the pac.txt yourself (commit gfwlist to your own repo/server) and point config at that stable URL.
  4. Rely on the previously cached pac file meanwhile — the plugin keeps the old rules when a download is invalid.

Example fix

// before
"overwall": { "pacFileUrl": "http://old.mirror.example/pac.txt" }
// after
"overwall": { "pacFileUrl": "https://raw.gitmirror.com/gfwlist/gfwlist/master/gfwlist.txt" }
Defensive patterns

Strategy: retry

Validate before calling

const res = await fetch(pacUrl)
const body = await res.text()
if (res.ok && body && body.length >= 100) applyPac(body)
else scheduleRetry(alternateUrl)

Try / catch

try { await downloadPacAsync() } catch (e) { loadCachedPac(); scheduleRetry() }

Prevention

When it happens

Trigger: downloadPacAsync fetches remotePacFileUrl, receives statusCode 200, but the body is empty or <100 bytes — typically a captive portal, anti-bot page, or misconfigured mirror returning a tiny 200 response.

Common situations: The remote pac URL is dead/renamed and the host returns a soft-200 stub; hotlink protection or CDN challenge pages; network environments (airports, hotels) intercepting HTTP(S) with portal responses; self-hosted pac file not uploaded correctly.

Related errors


AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31). Data as JSON: /api/errors/f8e99647a034d71d. Report an issue: GitHub.