alibaba/arthas · error · Error
元数据获取失败
Error message
元数据获取失败
What it means
Thrown by fetchJfrMetadata in jfr.ts when POSTing {namespace:'jfr-file', api:'metadata', target:fileId} to /arthas-api/analysis and the response JSON has code !== 1. The message falls back to '元数据获取失败' (metadata fetch failed) only when the server supplied no msg, so the real cause is usually in json.msg or the arthas backend log.
Source
Thrown at labs/arthas-jfr-frontend/src/services/jfr.ts:16
// 获取JFR文件分析维度元数据
export async function fetchJfrMetadata(fileId) {
const body = {
namespace: 'jfr-file',
api: 'metadata',
target: fileId,
parameters: {}
};
const res = await fetch('/arthas-api/analysis', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
const json = await res.json();
if (json.code !== 1) throw new Error(json.msg || '元数据获取失败');
return json;
}
// 获取火焰图数据
export async function fetchJfrFlameGraph({ fileId, dimension, include, taskSet }) {
const body = {
namespace: 'jfr-file',
api: 'flameGraph',
target: fileId,
parameters: { dimension, include, taskSet }
};
const res = await fetch('/arthas-api/analysis', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
const json = await res.json();
if (json.code !== 1) throw new Error(json.msg || '火焰图获取失败');View on GitHub (pinned to 21cf2e9ba5)
Solutions
- Inspect the actual json.msg in the response (it overrides this fallback) and the arthas backend log for the real error.
- Re-upload the JFR file and use the freshly returned fileId.
- Confirm the /arthas-api/analysis endpoint is reachable and the backend analysis service is running.
Example fix
// before
const meta = await fetchJfrMetadata({ fileId });
// after
try {
const meta = await fetchJfrMetadata({ fileId });
} catch (e) {
console.error('metadata failed for', fileId, e.message);
// re-upload then retry with new fileId
} Defensive patterns
Strategy: try-catch
Validate before calling
async function safeFetchMetadata(fileId) {
const res = await fetch('/arthas-api/analysis', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ namespace:'jfr-file', api:'metadata', target:fileId, parameters:{} }) });
if (!res.ok) throw new Error('HTTP ' + res.status);
const json = await res.json();
if (json.code !== 1) throw new Error(json.msg || 'metadata failed');
return json;
} Try / catch
try { const meta = await fetchJfrMetadata({ fileId }); }
catch (e) { showError(e.message); await reuploadJfr(); } Prevention
- Validate fileId is fresh before calling.
- Surface json.msg to the user instead of the generic fallback.
- Check backend connectivity first.
When it happens
Trigger: fileId refers to a JFR file that was not uploaded/expired; the arthas analysis backend is unreachable or errored; res.json() succeeded but code is an error code with a server msg.
Common situations: Frontend holds a stale fileId after the upload expired; backend arthas service down; the JFR file failed to parse on the server side.
Related errors
- 火焰图获取失败
- Could not find an available tcp port in the range [%d, %d] a
- Arthas server did not start after attach (no listener on {ip
- '{s}' is not a valid size. Should be numeric value followed
- '{s}' is not a valid timespan. Shoule be numeric value follo
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/d0fd5961529e7165.
Report an issue: GitHub.