Skip to content

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Sep 30, 2025

We were seeing some flakes in CI such as https://github.com/cloudflare/workers-sdk/actions/runs/18130487486/job/51595708301?pr=10766#step:6:9893

I discussed with the D&C team and they identified that this is a problem internally but there is not a clear fix at this stage.
They confirmed that an acceptable mitigation would be to retry (a few times) the request if it fails with a 500 response.


Notable aspects of this PR:

  • the utility function was writing messages to console.log() when retrying but this seems wrong, since the user shouldn't care about this - these logs have been moved to console.debug().
  • the utility function only retried 5xx errors but the fetchRequest() helper did not provide the response status to the new APIError so these were not being retried - this has now been threaded through,

@petebacondarwin petebacondarwin requested a review from a team as a code owner September 30, 2025 21:01
@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2025

🦋 Changeset detected

Latest commit: c95a0d7

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main pbd/wrangler/cope-with-subdomain-request-failure might be a good starting point.

Notes:

  • your PR branch should be named v3-backport-10832
  • add the skip-v3-pr label to the current PR to stop this workflow from failing
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 30, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10832 

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10832 

miniflare

npm i https://pkg.pr.new/miniflare@10832 

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10832 

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10832 

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10832 

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10832 

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10832 

wrangler

npm i https://pkg.pr.new/wrangler@10832 

commit: c95a0d7

beforeEach(() => {
const level = logger.loggerLevel;
logger.loggerLevel = "debug";
return () => (logger.loggerLevel = level);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, I didn't know about that way to restore values

abortSignal,
apiToken
);
const { response: json, status } = await fetchInternal<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: I really think the return type should be a cast... I mean it is but it should be explicit vs templated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is tricky to make it a cast as it is the response.result property that needs casting.

success: true,
errors: [],
messages: [],
} as ResponseType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would satisfies work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because ResponseType is an unknown type parameter at this point.

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nits but LGTM

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Oct 1, 2025
@petebacondarwin petebacondarwin force-pushed the pbd/wrangler/cope-with-subdomain-request-failure branch from 2f21c30 to 024c51d Compare October 1, 2025 09:38
Comment on lines +116 to +131
while (flakeCount > 0) {
flakeCount--;
handlers.unshift(
http.post(
url,
() =>
HttpResponse.json(
createFetchResult(null, false, [
{ code: 10013, message: "An unknown error has occurred." },
]),
{ status: 500 }
),
{ once: true }
)
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe just remove the { once: true } in the original handler? We are resetting handlers after each tests anyway, so I don't see a strong reason to use once here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually on purpose. It guarantees that the test will fail if more than one request hits this endpoint.

@petebacondarwin petebacondarwin force-pushed the pbd/wrangler/cope-with-subdomain-request-failure branch from 024c51d to dc88a7c Compare October 1, 2025 09:48
@petebacondarwin petebacondarwin force-pushed the pbd/wrangler/cope-with-subdomain-request-failure branch from dc88a7c to c95a0d7 Compare October 1, 2025 10:27
@petebacondarwin petebacondarwin added the skip-v3-pr Skip validation of presence of a v3 backport PR label Oct 1, 2025
@petebacondarwin petebacondarwin merged commit f9d37db into main Oct 1, 2025
45 of 48 checks passed
@petebacondarwin petebacondarwin deleted the pbd/wrangler/cope-with-subdomain-request-failure branch October 1, 2025 11:33
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-flake skip-v3-pr Skip validation of presence of a v3 backport PR

3 participants