Unverified Commit ebc435d8 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

[test] app-basepath less agressive request reading (#86740)

Hopefully helps with this
```
  ● app dir - basepath › should properly stream an internal server action redirect() with a relative URL

    request.allHeaders: Target page, context or browser has been closed

      77 |         beforePageLoad(page) {
      78 |           page.on('request', (request) => {
    > 79 |             return request.allHeaders().then((headers) => {
         |                            ^
      80 |               if (
      81 |                 headers['rsc'] === '1' &&
      82 |                 // Prefetches also include `rsc`

      at Page.allHeaders (e2e/app-dir/app-basepath/index.test.ts:79:28)
```
parent 2dda444c
......@@ -75,16 +75,29 @@ describe('app dir - basepath', () => {
let rscRequests = []
const browser = await next.browser(path, {
beforePageLoad(page) {
page.on('request', (request) => {
return request.allHeaders().then((headers) => {
page.on('request', async (request) => {
let headers: { [key: string]: string }
try {
headers = await request.allHeaders()
} catch (e) {
if (
headers['rsc'] === '1' &&
// Prefetches also include `rsc`
headers['next-router-prefetch'] !== '1'
e.message.includes(
'Target page, context or browser has been closed'
)
) {
rscRequests.push(request.url())
// Ignore errors caused by closed browser during test teardown
return
}
})
throw e
}
if (
headers['rsc'] === '1' &&
// Prefetches also include `rsc`
headers['next-router-prefetch'] !== '1'
) {
rscRequests.push(request.url())
}
})
},
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment