Unverified Commit 50ef635c authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Fall back loading chunks for sourcemap tracing (#61790)

This implements falling back to try multiple locations loading chunks
for sourcemap tracing.

Unfortunately, when RSC replays server errors on the client, it does not
carry over the [0] symbol used to annotate server frames. Instead,
errors are recreated by React and only include the message and stack.

This allows more tests to pass, as we are able to correctly trace stack
frames by loading the appropriate server chunk.

Closes PACK-2442
parent 775e8986
...@@ -830,25 +830,30 @@ pub async fn project_trace_source( ...@@ -830,25 +830,30 @@ pub async fn project_trace_source(
return Ok(None); return Ok(None);
}; };
let path = if frame.is_server { let server_path = project
project
.container .container
.project() .project()
.node_root() .node_root()
.join(chunk_base.to_owned()) .join(chunk_base.to_owned());
} else {
project let client_path = project
.container .container
.project() .project()
.client_relative_path() .client_relative_path()
.join(chunk_base.to_owned()) .join(chunk_base.to_owned());
};
let map = project let mut map_result = project
.container .container
.get_source_map(path, module) .get_source_map(server_path, module.clone())
.await? .await;
.context("chunk/module is missing a sourcemap")?; if map_result.is_err() {
// If the chunk doesn't exist as a server chunk, try a client chunk.
// TODO: Properly tag all server chunks and use the `isServer` query param.
// Currently, this is inaccurate as it does not cover RSC server
// chunks.
map_result = project.container.get_source_map(client_path, module).await;
}
let map = map_result?.context("chunk/module is missing a sourcemap")?;
let Some(line) = frame.line else { let Some(line) = frame.line else {
return Ok(None); return Ok(None);
......
...@@ -982,12 +982,11 @@ ...@@ -982,12 +982,11 @@
"test/development/acceptance-app/ReactRefreshRegression.test.ts": { "test/development/acceptance-app/ReactRefreshRegression.test.ts": {
"passed": [ "passed": [
"ReactRefreshRegression app can fast refresh a page with static generation", "ReactRefreshRegression app can fast refresh a page with static generation",
"ReactRefreshRegression app shows an overlay for server-side error in client component"
],
"failed": [
"ReactRefreshRegression app shows an overlay for anonymous function server-side error", "ReactRefreshRegression app shows an overlay for anonymous function server-side error",
"ReactRefreshRegression app shows an overlay for server-side error in client component",
"ReactRefreshRegression app shows an overlay for server-side error in server component" "ReactRefreshRegression app shows an overlay for server-side error in server component"
], ],
"failed": [],
"pending": [ "pending": [
"ReactRefreshRegression app Turbopack skipped tests custom loader mdx should have Fast Refresh enabled", "ReactRefreshRegression app Turbopack skipped tests custom loader mdx should have Fast Refresh enabled",
"ReactRefreshRegression app styled-components hydration mismatch" "ReactRefreshRegression app styled-components hydration mismatch"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment