Files
Benjamin WoodruffandGitHub 07b3ae71d1 chore: Attempt to fix ppr-partial-hydration flakiness (#84672)
Write to a marker file to determine when the slow server component finishes rendering instead of trying to sleep for some fixed amount of time.
2025-10-16 19:38:52 -07:00

21 lines
522 B
TypeScript

import { setTimeout } from 'node:timers/promises'
import { access } from 'node:fs/promises'
import path from 'node:path'
import React from 'react'
export default async function waitForMarkerFile() {
const signal = React.cacheSignal()
if (!signal) {
throw new Error('cacheSignal returned null, are we not rendering?')
}
while (true) {
try {
await access(path.join(process.cwd(), 'slowComponentReady'))
return
} catch (e) {
await setTimeout(100, { signal })
continue
}
}
}