Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
Playwright: "route.continue" occasionally gives error when blocking tracking scripts

I've got a synthetic monitoring test that has been running fine. I've added some code to block third-party ad tracking and analytic scripts to speed up the tests (and not skew analytics), as recommended here: https://scrapingant.com/blog/block-requests-playwright.

At the top of each test I've got this:

await page.route('**/*', filterResources)

And the filterResources method is defined as follows:

const DOMAIN_EXCLUSIONS = [
    'connect.facebook.net',
    'px.ads.linkedin.com',
    [...]
]

module.exports = (route) => {
    let matches = DOMAIN_EXCLUSIONS.filter((domain) => {
        return route.request().url().startsWith('https://' + domain)
    })
    return matches.length ? route.abort() : route.continue()
}

Now occasionally the following error will be thrown, and the test fails:

route.continue: Target page, context or browser has been closed

This maybe happens in one every 6-8 runs.

Is this because the page navigates away while some requests are still outstanding, because Playwright believes the page is already fully loaded? I'm using the proper awaits and the test was working fine before.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm catching and solving the promise now, and the issue doesn't seem to happen any more:

if (matches.length) {
    return route.abort()
}

return route.continue().catch(() => {})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda