enableDiskCache 缓存命中问题
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
当我开启了硬盘缓存,可是我还加了一个元数据获取失败兜底函数,这个时候只会走硬盘缓存逻辑,兜底函数不生效了
const obj = {
enableDiskCache: true,
apiPrefix: item.apiPrefix,
versionId: item.version,
hook: {
beforeAppendAssetNode(passCtx) {
const { url, setAssetUrl } = passCtx;
const jsdelivrUrl = url.replace('https://unpkg.com', item.apiPrefix);
setAssetUrl(jsdelivrUrl);
},
onFetchMetaFailed(params) {
// 返回一份前端预设的元数据对象,用于兜底
console.log('开始走兜底逻辑', params);
console.log('备用cdn数据', _DATA);
return _DATA;
},
},
};
try {
const helMicro = await import('hel-micro');
SDK = await helMicro.preFetchLib(item.sdk, obj);
} catch (e) {
console.log('捕获到异常错误', e);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the preFetchLib entry point and trace the enableDiskCache path alongside the onFetchMetaFailed hook. Reproduce the case with disk caching enabled and a metadata-fetch failure, then verify that the documented fallback behavior occurs and add or update the relevant test if one exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100