diff --git a/packages/plugin-rsc/e2e/fixture.ts b/packages/plugin-rsc/e2e/fixture.ts index 5835e57d9..e2c98c2e5 100644 --- a/packages/plugin-rsc/e2e/fixture.ts +++ b/packages/plugin-rsc/e2e/fixture.ts @@ -198,6 +198,10 @@ export async function setupIsolatedFixture(options: { dest: string overrides?: Record }) { + // Allow 60s for the calling `beforeAll` hook, because `pnpm i` hits the + // network and can exceed the default 30s on macOS runners. + test.setTimeout(60_000) + // copy fixture fs.rmSync(options.dest, { recursive: true, force: true }) fs.cpSync(options.src, options.dest, { diff --git a/packages/plugin-rsc/e2e/use-cache-persistent.test.ts b/packages/plugin-rsc/e2e/use-cache-persistent.test.ts index 186b4f72e..1a9b346f4 100644 --- a/packages/plugin-rsc/e2e/use-cache-persistent.test.ts +++ b/packages/plugin-rsc/e2e/use-cache-persistent.test.ts @@ -112,7 +112,9 @@ function defineDevTests(f: Fixture) { await expect(executionCount).toHaveText('1') // Editing the cached function advances its module generation. - action.edit((code) => code.replace('body-v1', 'body-v2')) + await editServerModule(page, () => + action.edit((code) => code.replace('body-v1', 'body-v2')), + ) await page.reload() await waitForHydration(page) await expectResultAfterUpdate( @@ -123,7 +125,9 @@ function defineDevTests(f: Fixture) { ) // Editing a direct dependency invalidates the importing cache module. - direct.edit((code) => code.replace('direct-v1', 'direct-v2')) + await editServerModule(page, () => + direct.edit((code) => code.replace('direct-v1', 'direct-v2')), + ) await page.reload() await waitForHydration(page) await expectResultAfterUpdate( @@ -134,7 +138,9 @@ function defineDevTests(f: Fixture) { ) // Reverse-importer traversal also reaches transitive dependencies. - transitive.edit((code) => code.replace('transitive-v1', 'transitive-v2')) + await editServerModule(page, () => + transitive.edit((code) => code.replace('transitive-v1', 'transitive-v2')), + ) await page.reload() await waitForHydration(page) await expectResultAfterUpdate( @@ -159,6 +165,19 @@ function defineDevTests(f: Fixture) { }) } +// Edit a server module and wait for the `rsc:update` refetch it triggers. +// Reloading before that finishes can abort the refetch (an unhandled +// `TypeError: Load failed` in WebKit), or let the late update reach the +// reloaded page before it has hydrated. +async function editServerModule(page: Page, edit: () => void) { + const refetch = page.waitForResponse( + (response) => + response.request().method() === 'GET' && response.url().includes('_.rsc'), + ) + edit() + await (await refetch).finished() +} + async function expectResultAfterUpdate( page: Page, form: Locator,