<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1" -->

---
title: Playwright waitForResponse: Fix Network Race Flakes in CI
description: Playwright's waitForResponse flakes in CI when the wait is created after the click instead of before it. Creating the promise first, then clicking, then...
canonical: https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Playwright waitForResponse: Fix Network Race Flakes in CI | daily.dev
og:description: Playwright's waitForResponse flakes in CI when the wait is created after the click instead of before it. Creating the promise first, then clicking, then...
og:url: https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1
og:image: https://api.daily.dev/og/posts/xazXikKf1.png
og:image:alt: Playwright waitForResponse: Fix Network Race Flakes in CI
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Playwright waitForResponse: Fix Network Race Flakes in CI

**[Currents](https://daily.dev/sources/currents)** · 15 min read · 0 upvotes · 0 comments

## Summary

Playwright's waitForResponse flakes in CI when the wait is created after the click instead of before it. Creating the promise first, then clicking, then awaiting the promise fixes the race, since an await on the click delays the wait's creation until the response may already be gone. The default waitForResponse timeout is 30 seconds, matching Playwright Test's default test timeout, so a missed wait silently eats the whole test budget. Loose glob matchers like '**/api/*' also fail once URLs gain query strings or ID segments, and a RegExp matcher once resolved on a CORS preflight OPTIONS call instead of the real POST (issue #36311). The trace viewer shows each wait's span starting at creation, not await, which pinpoints whether a wait started late or matched the wrong call.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://currents.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci>

## Questions this post answers

### Why does my Playwright waitForResponse test pass locally but time out in CI?

The wait is likely created after the click instead of before it. Awaiting the click first delays the wait's existence until after the response may have already landed, and whether that gap matters depends on timing, which differs between a laptop and a busy CI runner. Fix it by creating the waitForResponse promise before the click, then awaiting it after.

_Teams chasing CI-only test flakes can track recurring failure patterns with daily.dev._

### Why does my Playwright waitForResponse glob pattern never match the request URL?

A glob pattern must match the entire URL, not just part of it, and a single asterisk matches any characters except a slash. A glob like '**/api/*' fails against a path like '/api/orders/42' because of the extra segment. A double-asterisk glob matches across slashes, or a RegExp handles query strings and dynamic segments better.

_Developers debugging brittle URL matchers can compare Playwright testing patterns on daily.dev._

### What is the default timeout for Playwright's waitForResponse and how does it interact with the test timeout?

The waitForResponse timeout is in milliseconds and defaults to 30 seconds, the same as Playwright Test's default per-test timeout, which also includes fixture setup and beforeEach hooks. Passing 0 disables it. Give the wait its own explicit timeout shorter than the remaining test budget so a missed response fails in the wait itself rather than at the test timeout.

_Engineers tuning CI timeout budgets can find more Playwright configuration guidance on daily.dev._

## Similar posts on daily.dev

- [Mastering waits and timeouts in Playwright](https://daily.dev/posts/mastering-waits-and-timeouts-in-playwright-a1pw100gb) · CircleCI · 0 upvotes · 0 comments
- [Claude Code Playwright MCP: Fix Tests That Fail in CI](https://daily.dev/posts/claude-code-playwright-mcp-fix-tests-that-fail-in-ci-pbk4f7epo) · Currents · 2 upvotes · 2 comments
- [Playwright Api Testing: A Complete Guide \(2026\)](https://daily.dev/posts/playwright-api-testing-a-complete-guide-2026--humzj6z2y) · Ruby Flow · 2 upvotes · 0 comments
- [How to analyze Playwright traces](https://daily.dev/posts/how-to-analyze-playwright-traces-zowzprzht) · RUBYLAND · 0 upvotes · 0 comments
- [I Thought My E2E Tests Were Slow Because of Bad Selectors. I Was Wrong.](https://daily.dev/posts/i-thought-my-e2e-tests-were-slow-because-of-bad-selectors-i-was-wrong--fb8bziaos) · Medium · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#cicd](https://daily.dev/tags/cicd), [#graphql](https://daily.dev/tags/graphql)

[View this post on daily.dev](https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Playwright waitForResponse: Fix Network Race Flakes in CI","url":"https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1"},"datePublished":"2026-10-26T16:03:54.162Z","dateModified":"2026-10-26T16:04:22.493Z","description":"Playwright's waitForResponse flakes in CI when the wait is created after the click instead of before it. Creating the promise first, then clicking, then...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4c74f3fd91eaca21e7d6dd980627ed33?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4c74f3fd91eaca21e7d6dd980627ed33?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Currents","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Currents","logo":"https://media.daily.dev/image/upload/s--RxsiMZ1S--/f_auto,q_auto/v1788684994/logos/currents?_a=BAMAMicg0","url":"https://daily.dev/sources/currents"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,cicd,graphql","timeRequired":"PT15M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Currents","item":"https://daily.dev/sources/currents"},{"@type":"ListItem","position":3,"name":"Playwright waitForResponse: Fix Network Race Flakes in CI"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/playwright-waitforresponse-fix-network-race-flakes-in-ci-xazxikkf1#faq","mainEntity":[{"@type":"Question","name":"Why does my Playwright waitForResponse test pass locally but time out in CI?","acceptedAnswer":{"@type":"Answer","text":"The wait is likely created after the click instead of before it. Awaiting the click first delays the wait's existence until after the response may have already landed, and whether that gap matters depends on timing, which differs between a laptop and a busy CI runner. Fix it by creating the waitForResponse promise before the click, then awaiting it after. Teams chasing CI-only test flakes can track recurring failure patterns with daily.dev."}},{"@type":"Question","name":"Why does my Playwright waitForResponse glob pattern never match the request URL?","acceptedAnswer":{"@type":"Answer","text":"A glob pattern must match the entire URL, not just part of it, and a single asterisk matches any characters except a slash. A glob like '**/api/*' fails against a path like '/api/orders/42' because of the extra segment. A double-asterisk glob matches across slashes, or a RegExp handles query strings and dynamic segments better. Developers debugging brittle URL matchers can compare Playwright testing patterns on daily.dev."}},{"@type":"Question","name":"What is the default timeout for Playwright's waitForResponse and how does it interact with the test timeout?","acceptedAnswer":{"@type":"Answer","text":"The waitForResponse timeout is in milliseconds and defaults to 30 seconds, the same as Playwright Test's default per-test timeout, which also includes fixture setup and beforeEach hooks. Passing 0 disables it. Give the wait its own explicit timeout shorter than the remaining test budget so a missed response fails in the wait itself rather than at the test timeout. Engineers tuning CI timeout budgets can find more Playwright configuration guidance on daily.dev."}}]}
```

