Skip to content

[next@15] Prefetch priority not respected(?) #2678

Open
@serhalp

Description

@serhalp

This seems to have started in https://github.com/vercel/next.js/releases/tag/v15.0.0-canary.154 or https://github.com/vercel/next.js/releases/tag/v15.0.0-canary.155. But this could be a red herring — we landed multiple other fixes to the e2e tests right around this time, which may have been obscuring this latent issue.

  ● app dir - prefetching › fetch priority › should prefetch links in viewport with low priority
    expect(received).toBe(expected) // Object.is equality
    Expected: true
    Received: false
      402 |       await retry(async () => {
      403 |         expect(requests.length).toBeGreaterThan(0)
    > 404 |         expect(requests.every((req) => req.priority === 'low')).toBe(true)
          |                                                                 ^
      405 |       })
      406 |     })
      407 |
      at toBe (e2e/app-dir/app-prefetch/prefetching.test.ts:404:65)
      at fn (lib/next-test-utils.ts:806:20)
      at Object.<anonymous> (e2e/app-dir/app-prefetch/prefetching.test.ts:402:7)
  ● app dir - prefetching › fetch priority › should prefetch with high priority when navigating to a page without a prefetch entry
    expect(received).toBe(expected) // Object.is equality
    Expected: "high"
    Received: undefined
      430 |       await retry(async () => {
      431 |         expect(requests.length).toBe(1)
    > 432 |         expect(requests[0].priority).toBe('high')
          |                                      ^
      433 |       })
      434 |     })
      435 |
      at toBe (e2e/app-dir/app-prefetch/prefetching.test.ts:432:38)
      at fn (lib/next-test-utils.ts:806:20)
      at Object.<anonymous> (e2e/app-dir/app-prefetch/prefetching.test.ts:430:7)
  ● app dir - prefetching › fetch priority › should have an auto priority for all other fetch operations
    expect(received).toBe(expected) // Object.is equality
    Expected: "low"
    Received: undefined
      459 |         )
      460 |         expect(dashboardRequests.length).toBe(2)
    > 461 |         expect(dashboardRequests[0].priority).toBe('low') // the first request is the prefetch
          |                                               ^
      462 |         expect(dashboardRequests[1].priority).toBe('auto') // the second request is the lazy fetch to fill in missing data
      463 |       })
      464 |     })
      at toBe (e2e/app-dir/app-prefetch/prefetching.test.ts:461:47)
      at fn (lib/next-test-utils.ts:806:20)
      at Object.<anonymous> (e2e/app-dir/app-prefetch/prefetching.test.ts:456:7)
Test Suites: 1 failed, 1 total
Tests:       3 failed, 14 passed, 17 total

File: test/e2e/app-dir/app-prefetch/prefetching.test.ts

The logic is here: https://github.com/vercel/next.js/blob/4837a67fb9bc7199e48cd8bd2cc42659b17dfacc/packages/next/src/client/components/router-reducer/fetch-server-response.ts#L153-L165.

Our hypothesis is that it's just a test setup issue related to __NEXT_TEST_MODE. Reading through the code it seems like it's next.js that should be passing it to the spawned next process, but who knows.

Data

The following is parsed automatically by the Next.js repo e2e test report generator.

test: test/e2e/app-dir/app-prefetch/prefetching.test.ts
reason: Prefetch priority is not threaded through to fetch calls

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions