Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 adjust chunk cache key for edge case #781

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

stormslowly
Copy link
Member

.

@sorrycc
Copy link
Member

sorrycc commented Dec 12, 2023

补个 e2e 用例?

@stormslowly
Copy link
Member Author

文件数太少了,触发了 cached 宏内部锁机制失效。相同 cache key,各自都调用了 inner ,所以复现不了问题。

pub(crate) fn render_css_chunk(chunk_pot: &ChunkPot, context: &Arc<Context>) -> Result<ChunkFile> {
    use cached::Cached;
    let key = { chunk_pot.stylesheet.as_ref().unwrap().raw_hash };
    {
        let mut cache = RENDER_CSS_CHUNK.lock().unwrap();
        if let Some(result) = cache.cache_get(&key) { return Ok(result.clone()); }
    } 

    fn inner(chunk_pot: &ChunkPot, context: &Arc<Context>) -> Result<ChunkFile> {}
    
    let result = inner(chunk_pot, context);
    let mut cache = RENDER_CSS_CHUNK.lock().unwrap();
    if let Ok(result) = &result { cache.cache_set(key, result.clone()); }
    result
}

@stormslowly
Copy link
Member Author

用例也发现不了,暂时不加了;
还是 build 阶段去缓存 RIO 更高一些

@sorrycc sorrycc merged commit 057da4b into master Dec 13, 2023
@delete-merged-branch delete-merged-branch bot deleted the fix/chunk_css_conflict branch December 13, 2023 02:58
@stormslowly stormslowly restored the fix/chunk_css_conflict branch March 25, 2024 05:24
@stormslowly stormslowly deleted the fix/chunk_css_conflict branch August 9, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants