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,8 +75,22 @@ describe('app dir - basepath', () => { ...@@ -75,8 +75,22 @@ describe('app dir - basepath', () => {
let rscRequests = [] let rscRequests = []
const browser = await next.browser(path, { const browser = await next.browser(path, {
beforePageLoad(page) { beforePageLoad(page) {
page.on('request', (request) => { page.on('request', async (request) => {
return request.allHeaders().then((headers) => { let headers: { [key: string]: string }
try {
headers = await request.allHeaders()
} catch (e) {
if (
e.message.includes(
'Target page, context or browser has been closed'
)
) {
// Ignore errors caused by closed browser during test teardown
return
}
throw e
}
if ( if (
headers['rsc'] === '1' && headers['rsc'] === '1' &&
// Prefetches also include `rsc` // Prefetches also include `rsc`
...@@ -85,7 +99,6 @@ describe('app dir - basepath', () => { ...@@ -85,7 +99,6 @@ describe('app dir - basepath', () => {
rscRequests.push(request.url()) 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