diff --git a/packages/gatsby/cache-dir/static-entry.js b/packages/gatsby/cache-dir/static-entry.js index 55b143c226be8..475170c202652 100644 --- a/packages/gatsby/cache-dir/static-entry.js +++ b/packages/gatsby/cache-dir/static-entry.js @@ -556,12 +556,9 @@ export async function renderSlice({ slice, staticQueryContext, props = {} }) { } const sliceElement = ( - - - - - + ) + const sliceWrappedWithWrapRootElement = apiRunner( `wrapRootElement`, { element: sliceElement }, @@ -571,15 +568,26 @@ export async function renderSlice({ slice, staticQueryContext, props = {} }) { } ).pop() + const sliceWrappedWithWrapRootElementAndContexts = ( + + + {sliceWrappedWithWrapRootElement} + + + ) + const writableStream = new WritableAsPromise() - const { pipe } = renderToPipeableStream(sliceWrappedWithWrapRootElement, { - onAllReady() { - pipe(writableStream) - }, - onError(error) { - writableStream.destroy(error) - }, - }) + const { pipe } = renderToPipeableStream( + sliceWrappedWithWrapRootElementAndContexts, + { + onAllReady() { + pipe(writableStream) + }, + onError(error) { + writableStream.destroy(error) + }, + } + ) return await writableStream }