docmirror/dev-sidecar · warning
下载远程配置成功,但内容为空:
Error message
下载远程配置成功,但内容为空:
What it means
doDownloadRemoteConfig resolves successfully-but-emptily (resolve() with no value) when the remote config URL returns HTTP 200 but the body is null or shorter than 2 characters. A warning is logged with the URL. The empty body is treated as 'no override' rather than an error, so defaults/other config layers are used.
Source
Thrown at packages/core/src/config-api.js:71
return new Promise((resolve, reject) => {
log.info('开始下载远程配置:', remoteConfigUrl)
const headers = {
'Cache-Control': 'no-cache', // 禁止使用缓存
'Pragma': 'no-cache', // 禁止使用缓存
}
if (remoteConfigUrl.startsWith('https://raw.githubusercontent.com/')) {
headers['Server-Name'] = 'baidu.com'
}
request(remoteConfigUrl, { headers }, (error, response, body) => {
if (error) {
log.error(`下载远程配置失败: ${remoteConfigUrl}, error:`, error, ', response:', response, ', body:', body)
reject(error)
return
}
if (response && response.statusCode === 200) {
if (body == null || body.length < 2) {
log.warn('下载远程配置成功,但内容为空:', remoteConfigUrl)
resolve()
return
} else {
log.info('下载远程配置成功:', remoteConfigUrl)
}
// 尝试解析远程配置,如果解析失败,则不保存它
let remoteConfig
try {
remoteConfig = jsonApi.parse(body)
} catch {
log.error(`远程配置内容格式不正确, url: ${remoteConfigUrl}, body: ${body}`)
remoteConfig = null
}
if (remoteConfig != null) {
const remoteSavePath = configLoader.getRemoteConfigPath(suffix)
try {View on GitHub (pinned to 7710cd56cc)
Solutions
- Open the remoteConfigUrl in a browser and confirm it actually serves non-empty JSON5 content
- Fix the source file (commit/push the intended config) if it was uploaded empty
- Verify the URL points to the raw file, not an HTML wrapper page
- If the empty config is intentional, ignore the warning — defaults and local overrides still apply
Example fix
// before (empty file on host)
// after — ensure remote config file contains at least valid content, e.g.
{ }
Defensive patterns
Strategy: fallback
Validate before calling
async function remoteConfigHasContent(url) {
const res = await fetch(url)
const text = await res.text()
return res.status === 200 && text.trim().length >= 2
}
// verify before configuring remoteConfigUrl, or warn the user Type guard
function isEmptyRemoteBody(body) {
return body == null || body.length < 2
} Try / catch
const cfg = await downloadRemoteConfig(url) // resolves undefined on empty
if (cfg == null) {
log.warn('Remote config empty; falling back to defaults + local overrides')
} Prevention
- Verify the remote config URL serves real content before wiring it into config
- Point at raw file URLs (raw.githubusercontent / raw gitee), not HTML pages
- Keep remote config files non-empty and valid JSON5 even when 'empty' means no overrides — use '{}'
- Remember empty remote config is non-fatal: defaults and ~/.dev-sidecar/config.json still apply
When it happens
Trigger: Downloading a remote shared/personal config (config.remoteConfigUrl) where the server responds 200 with an empty body: a zero-byte file on the static host, a 200-wrapped error page stripped of content, or a CDN returning an empty successful response.
Common situations: User published an empty config file to gitee/github raw; wrong URL pointing to an empty placeholder; private repo/CDN returning empty 200 without auth; file truncated on upload.
Related errors
- 下载远程 domestic-domain-allowlist.txt 文件成功,但内容为空或内容太短,判断为无效的 do
- Unknown type DNS: ${server}, provider: ${provider}
- [speed] test error: ${this.hostname} ➜ ${item.host}:${this
- [speed] test by TCP error:
- 远程配置对象为空:
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/d3503be19841dbfb.
Report an issue: GitHub.