Skip to content

Commit

Permalink
reduce ContentSource::get resolve tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Feb 17, 2023
1 parent 40e8a7d commit 4494954
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions crates/turbopack-dev-server/src/source/combined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ impl PausableCombinedContentSource {
// we've skipped to exactly the source which requested data. Requery the source
// with it's partially computed path and needed data.
let result = match pending.take() {
Some(pending) => pending.source.get(&pending.path, mem::take(&mut data)),
None => source.get(path, Default::default()),
Some(pending) => pending
.source
.resolve()
.await?
.get(&pending.path, mem::take(&mut data)),
None => source.resolve().await?.get(path, Default::default()),
};

let res = result.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-dev-server/src/source/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub async fn resolve_source_request(
let new_asset_path =
urlencoding::decode(&new_uri.path()[1..])?.into_owned();

current_source = new_source;
current_source = new_source.resolve().await?;
request_overwrites.uri = new_uri;
current_asset_path = new_asset_path;
data = ContentSourceData::default();
Expand Down
8 changes: 6 additions & 2 deletions crates/turbopack-dev-server/src/source/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ impl RouterContentSource {
#[turbo_tasks::value_impl]
impl ContentSource for RouterContentSource {
#[turbo_tasks::function]
fn get(&self, path: &str, data: Value<ContentSourceData>) -> ContentSourceResultVc {
async fn get(
&self,
path: &str,
data: Value<ContentSourceData>,
) -> Result<ContentSourceResultVc> {
let (source, path) = self.get_source(path);
source.get(path, data)
Ok(source.resolve().await?.get(path, data))
}

#[turbo_tasks::function]
Expand Down

0 comments on commit 4494954

Please sign in to comment.