Skip to content

Commit

Permalink
handle updates from different versions (avoid panic) (vercel#172)
Browse files Browse the repository at this point in the history
Avoid the panic when updating from NotFoundVersion to
EcmascriptChunkVersion
  • Loading branch information
sokra authored Oct 21, 2022
1 parent d5eb75e commit 8d3d7e5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/turbopack-ecmascript/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use turbopack_core::{
},
reference::{AssetReferenceVc, AssetReferencesVc},
version::{
PartialUpdate, Update, UpdateVc, Version, VersionVc, VersionedContent, VersionedContentVc,
PartialUpdate, TotalUpdate, Update, UpdateVc, Version, VersionVc, VersionedContent,
VersionedContentVc,
},
};

Expand Down Expand Up @@ -662,10 +663,16 @@ impl VersionedContent for EcmascriptChunkContent {
self_vc: EcmascriptChunkContentVc,
from_version: VersionVc,
) -> Result<UpdateVc> {
let from_version = EcmascriptChunkVersionVc::resolve_from(from_version)
.await?
.expect("version must be an `EcmascriptChunkVersionVc`");
let to_version = self_vc.version();
let from_version =
if let Some(from) = EcmascriptChunkVersionVc::resolve_from(from_version).await? {
from
} else {
return Ok(Update::Total(TotalUpdate {
to: to_version.into(),
})
.cell());
};

let to = to_version.await?;
let from = from_version.await?;
Expand Down

0 comments on commit 8d3d7e5

Please sign in to comment.