Skip to content

fix: throw if fuliflled with unsupported status code#28539

Merged
yury-s merged 3 commits into
microsoft:mainfrom
yury-s:fulfill-invalid-status
Dec 8, 2023
Merged

fix: throw if fuliflled with unsupported status code#28539
yury-s merged 3 commits into
microsoft:mainfrom
yury-s:fulfill-invalid-status

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Dec 7, 2023

If request gets cancelled by the page before we fulfill it, we receive loadingFailed event. In that case we'll ignore interception error if any, otherwise the error will be propagated to the caller.

Fixes #28490

@yury-s yury-s force-pushed the fulfill-invalid-status branch from fb5e97b to a19bd95 Compare December 7, 2023 22:57
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread packages/playwright-core/src/server/network.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 8, 2023

Test results for "tests 1"

5 flaky ⚠️ [chromium] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks
⚠️ [chromium] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks
⚠️ [chromium] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks
⚠️ [firefox] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks
⚠️ [chromium] › library/tracing.spec.ts:239:5 › should not include trace resources from the previous chunks

21129 passed, 585 skipped
✔️✔️✔️

Merge workflow run.

@yury-s yury-s merged commit 119afdf into microsoft:main Dec 8, 2023
@yury-s yury-s deleted the fulfill-invalid-status branch December 8, 2023 00:57
yury-s added a commit that referenced this pull request Jan 26, 2024
We stopped catching all exceptions in
#28539 in hope that we'll
get loadingFailed even before Fetch.continue/fulfill command's error.
Turns out this is racy and may fail if the test cancels the request
while we are continuing it. The following test could in theory reproduce
it if stars align and the timing is good:

```js
it('page.continue on canceled request', async ({ page }) => {
  let resolveRoute;
  const routePromise = new Promise<Route>(f => resolveRoute = f);
  await page.route('http://test.com/x', resolveRoute);

  const evalPromise = page.evaluate(async () => {
    const abortController = new AbortController();
    (window as any).abortController = abortController;
    return fetch('http://test.com/x', { signal: abortController.signal }).catch(e => 'cancelled');
  });
  const route = await routePromise;
  void page.evaluate(() => (window as any).abortController.abort());
  await new Promise(f => setTimeout(f, 10));
  await route.continue();
  const req = await evalPromise;
  expect(req).toBe('cancelled');
});
```

Fixes #29123
yury-s added a commit to yury-s/playwright that referenced this pull request Jan 29, 2024
… route.continue

We stopped catching all exceptions in
microsoft#28539 in hope that we'll
get loadingFailed even before Fetch.continue/fulfill command's error.
Turns out this is racy and may fail if the test cancels the request
while we are continuing it. The following test could in theory reproduce
it if stars align and the timing is good:

```js
it('page.continue on canceled request', async ({ page }) => {
  let resolveRoute;
  const routePromise = new Promise<Route>(f => resolveRoute = f);
  await page.route('http://test.com/x', resolveRoute);

  const evalPromise = page.evaluate(async () => {
    const abortController = new AbortController();
    (window as any).abortController = abortController;
    return fetch('http://test.com/x', { signal: abortController.signal }).catch(e => 'cancelled');
  });
  const route = await routePromise;
  void page.evaluate(() => (window as any).abortController.abort());
  await new Promise(f => setTimeout(f, 10));
  await route.continue();
  const req = await evalPromise;
  expect(req).toBe('cancelled');
});
```

Fixes microsoft#29123
yury-s added a commit that referenced this pull request Jan 29, 2024
#29222)

…ntinue

We stopped catching all exceptions in
#28539 in hope that we'll
get loadingFailed even before Fetch.continue/fulfill command's error.
Turns out this is racy and may fail if the test cancels the request
while we are continuing it. The following test could in theory reproduce
it if stars align and the timing is good:

```js
it('page.continue on canceled request', async ({ page }) => {
  let resolveRoute;
  const routePromise = new Promise<Route>(f => resolveRoute = f);
  await page.route('http://test.com/x', resolveRoute);

  const evalPromise = page.evaluate(async () => {
    const abortController = new AbortController();
    (window as any).abortController = abortController;
    return fetch('http://test.com/x', { signal: abortController.signal }).catch(e => 'cancelled');
  });
  const route = await routePromise;
  void page.evaluate(() => (window as any).abortController.abort());
  await new Promise(f => setTimeout(f, 10));
  await route.continue();
  const req = await evalPromise;
  expect(req).toBe('cancelled');
});
```

Fixes #29123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Route fulfill with some status codes does not fulfill

2 participants