Unverified Commit 2abc8248 authored by Justin Ridgewell's avatar Justin Ridgewell Committed by GitHub

Turbopack: Use `SharedError` for body streaming (#47677)

Pending https://github.com/vercel/turbo/pull/4392 landing in Turbopack (and https://github.com/vercel/next.js/pull/47476 landing here), this removes `BodyError` and switches to `SharedError`. That should allow us to preserve the source chain of errors for when we finally display it to the dev, aiding debugging.
parent f978e700
This diff is collapsed.
...@@ -47,11 +47,11 @@ swc_emotion = { version = "0.29.10" } ...@@ -47,11 +47,11 @@ swc_emotion = { version = "0.29.10" }
testing = { version = "0.31.31" } testing = { version = "0.31.31" }
# Turbo crates # Turbo crates
turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230331.2" } turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230331.3" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230331.2" } turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230331.3" }
# [TODO]: need to refactor embed_directory! macro usage in next-core # [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230331.2" } turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230331.3" }
# General Deps # General Deps
......
...@@ -120,7 +120,7 @@ enum RouterIncomingMessage { ...@@ -120,7 +120,7 @@ enum RouterIncomingMessage {
Error { error: StructuredError }, Error { error: StructuredError },
} }
#[turbo_tasks::value(eq = "manual", cell = "new", serialization = "none")] #[turbo_tasks::value]
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub struct MiddlewareResponse { pub struct MiddlewareResponse {
pub status_code: u16, pub status_code: u16,
...@@ -129,8 +129,8 @@ pub struct MiddlewareResponse { ...@@ -129,8 +129,8 @@ pub struct MiddlewareResponse {
pub body: Stream<Result<Bytes, SharedError>>, pub body: Stream<Result<Bytes, SharedError>>,
} }
#[turbo_tasks::value(eq = "manual", cell = "new", serialization = "none")]
#[derive(Debug)] #[derive(Debug)]
#[turbo_tasks::value]
pub enum RouterResult { pub enum RouterResult {
Rewrite(RewriteResponse), Rewrite(RewriteResponse),
Middleware(MiddlewareResponse), Middleware(MiddlewareResponse),
......
...@@ -7,9 +7,9 @@ use turbo_binding::turbopack::{ ...@@ -7,9 +7,9 @@ use turbo_binding::turbopack::{
introspect::{Introspectable, IntrospectableChildrenVc, IntrospectableVc}, introspect::{Introspectable, IntrospectableChildrenVc, IntrospectableVc},
}, },
dev_server::source::{ dev_server::source::{
Body, BodyError, ContentSource, ContentSourceContent, ContentSourceData, Body, ContentSource, ContentSourceContent, ContentSourceData, ContentSourceDataVary,
ContentSourceDataVary, ContentSourceResultVc, ContentSourceVc, HeaderListVc, NeededData, ContentSourceResultVc, ContentSourceVc, HeaderListVc, NeededData, ProxyResult,
ProxyResult, RewriteBuilder, RewriteBuilder,
}, },
node::execution_context::ExecutionContextVc, node::execution_context::ExecutionContextVc,
}; };
...@@ -156,11 +156,7 @@ impl ContentSource for NextRouterContentSource { ...@@ -156,11 +156,7 @@ impl ContentSource for NextRouterContentSource {
ProxyResult { ProxyResult {
status: data.status_code, status: data.status_code,
headers: data.headers.clone(), headers: data.headers.clone(),
body: Body::from_stream(data.body.read().map(|chunk| { body: Body::from_stream(data.body.read()),
chunk.map_err(|e| {
BodyError::new(format!("error streaming proxied contents: {}", e))
})
})),
} }
.cell(), .cell(),
) )
......
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