Skip to content

Commit a12b098

Browse files
committed
[Cache Components] Validate static shell using dev stream
1 parent 3dafab9 commit a12b098

File tree

5 files changed

+531
-41
lines changed

5 files changed

+531
-41
lines changed

packages/next/errors.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,5 +898,6 @@
898898
"897": "Expected HTML document to start with doctype prefix",
899899
"898": "When using Cache Components, all `generateStaticParams` functions must return at least one result. This is to ensure that we can perform build-time validation that there is no other dynamic accesses that would cause a runtime error.\n\nLearn more: https://nextjs.org/docs/messages/empty-generate-static-params",
900900
"899": "Both \"%s\" and \"%s\" files are detected. Please use \"%s\" instead. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy",
901-
"900": "Both %s file \"./%s\" and %s file \"./%s\" are detected. Please use \"./%s\" only. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy"
901+
"900": "Both %s file \"./%s\" and %s file \"./%s\" are detected. Please use \"./%s\" only. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy",
902+
"901": "`accumulateStringChunks` received a chunk after deadline"
902903
}

packages/next/src/server/app-render/app-render-render-utils.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,55 @@ export function scheduleInSequentialTasks<R>(
3838
export function pipelineInSequentialTasks<A, B, C>(
3939
one: () => A,
4040
two: (a: A) => B,
41-
three: (b: B) => C | Promise<C>
41+
three: (b: B) => C
4242
): Promise<C> {
4343
if (process.env.NEXT_RUNTIME === 'edge') {
4444
throw new InvariantError(
4545
'`pipelineInSequentialTasks` should not be called in edge runtime.'
4646
)
4747
} else {
4848
return new Promise((resolve, reject) => {
49-
let oneResult: A | undefined = undefined
49+
let oneResult: A
5050
setTimeout(() => {
5151
try {
5252
oneResult = one()
5353
} catch (err) {
5454
clearTimeout(twoId)
5555
clearTimeout(threeId)
56+
clearTimeout(fourId)
5657
reject(err)
5758
}
5859
}, 0)
5960

60-
let twoResult: B | undefined = undefined
61+
let twoResult: B
6162
const twoId = setTimeout(() => {
6263
// if `one` threw, then this timeout would've been cleared,
6364
// so if we got here, we're guaranteed to have a value.
6465
try {
6566
twoResult = two(oneResult!)
6667
} catch (err) {
6768
clearTimeout(threeId)
69+
clearTimeout(fourId)
6870
reject(err)
6971
}
7072
}, 0)
7173

74+
let threeResult: C
7275
const threeId = setTimeout(() => {
7376
// if `two` threw, then this timeout would've been cleared,
7477
// so if we got here, we're guaranteed to have a value.
7578
try {
76-
resolve(three(twoResult!))
79+
threeResult = three(twoResult!)
7780
} catch (err) {
81+
clearTimeout(fourId)
7882
reject(err)
7983
}
8084
}, 0)
85+
86+
// We wait a task before resolving/rejecting
87+
const fourId = setTimeout(() => {
88+
resolve(threeResult)
89+
}, 0)
8190
})
8291
}
8392
}

0 commit comments

Comments
 (0)