Skip to content

Commit

Permalink
improve order of spans in tracing (#66516)
Browse files Browse the repository at this point in the history
### What?

awaits generating the output before calling into emitting

### Why?

this improve the order of spans in the tracing
  • Loading branch information
sokra committed Jun 4, 2024
1 parent 348b736 commit 82df2a8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ impl Endpoint for AppEndpoint {
}
};
async move {
let output = self.output();
let output = self.output().await?;
// Must use self.output_assets() instead of output.output_assets() to make it a
// single operation
let output_assets = self.output_assets();
Expand All @@ -1297,7 +1297,7 @@ impl Endpoint for AppEndpoint {
.await?
.clone_value();

let written_endpoint = match *output.await? {
let written_endpoint = match *output {
AppEndpointOutput::NodeJs { rsc_chunk, .. } => WrittenEndpoint::NodeJs {
server_entry_path: node_root_ref
.get_path_to(&*rsc_chunk.ident().path().await?)
Expand Down
1 change: 1 addition & 0 deletions packages/next-swc/crates/next-api/src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ impl Endpoint for InstrumentationEndpoint {
async move {
let this = self.await?;
let output_assets = self.output_assets();
let _ = output_assets.resolve().await?;
this.project
.emit_all_output_assets(Vc::cell(output_assets))
.await?;
Expand Down
1 change: 1 addition & 0 deletions packages/next-swc/crates/next-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ impl Endpoint for MiddlewareEndpoint {
async move {
let this = self.await?;
let output_assets = self.output_assets();
let _ = output_assets.resolve().await?;
this.project
.emit_all_output_assets(Vc::cell(output_assets))
.await?;
Expand Down
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-api/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ impl Endpoint for PageEndpoint {
}
};
async move {
let output = self.output();
let output = self.output().await?;
// Must use self.output_assets() instead of output.output_assets() to make it a
// single operation
let output_assets = self.output_assets();
Expand All @@ -1189,7 +1189,7 @@ impl Endpoint for PageEndpoint {
.clone_value();

let node_root = &node_root.await?;
let written_endpoint = match *output.await? {
let written_endpoint = match *output {
PageEndpointOutput::NodeJs { entry_chunk, .. } => WrittenEndpoint::NodeJs {
server_entry_path: node_root
.get_path_to(&*entry_chunk.ident().path().await?)
Expand Down

0 comments on commit 82df2a8

Please sign in to comment.