vitest-pool-workers: Support AbortSignal in fetch-mock#7032
vitest-pool-workers: Support AbortSignal in fetch-mock#7032emily-shen merged 2 commits intocloudflare:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 9794a39 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
| /** | ||
| * Mutate an Error instance so it passes either of the checks in isAbortError | ||
| */ | ||
| export function castAsAbortError(err: Error): Error { |
There was a problem hiding this comment.
Lifted from: https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/utils/isAbortError.ts#L19-L20
Guessing this would be preferred over making additions to the wrangler exports
87dcaec to
7eb5b47
Compare
fixtures/vitest-pool-workers-examples/misc/test/fetch-mock.test.ts
Outdated
Show resolved
Hide resolved
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-wrangler-7032You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7032/npm-package-wrangler-7032Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-wrangler-7032 dev path/to/script.jsAdditional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-create-cloudflare-7032 --no-auto-updatenpm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-cloudflare-kv-asset-handler-7032npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-miniflare-7032npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-cloudflare-pages-shared-7032npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-cloudflare-vitest-pool-workers-7032npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-cloudflare-workers-editor-shared-7032npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-cloudflare-workers-shared-7032npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11941549222/npm-package-cloudflare-workflows-shared-7032Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
|
@emily-shen is there any chance I can get a re-review on this? :) |
|
Hey, really sorry for the delay! I had a look earlier and it looks all good to me, but I'm not actually that familiar with this part of the codebase and probably not the best person to review this, will forward this to the team again 😅 cc @penalosa (when you get back) and @edmundhung if you could help with this PR :) |
d2bc6ac to
acd1ed5
Compare
@andyjessop the linked appears to be in regards to a client aborting the request to the worker, but this is for a request the worker is making to another service via fetch which in my manual testing appears to work okay 🤔 |
Appears unrelated to these changes e2e runs, and the documentation point is covered above Is there anything else you need from me? |
acd1ed5 to
e805ea8
Compare
e805ea8 to
9794a39
Compare
|
Congratulations @Codex-, the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cm3zxwf8718910cmnohdto81a This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. |
What this PR solves / how to test
This PR introduces support for
AbortSignalto fetch-mock, allowing signals to 'abort' requests during tests as they do at actual runtime. This makes it significantly easier to test this behaviour when writing tests that rely on signals and their behaviours.Author has addressed the following
AbortSignalwhen wanting to time out fetch calls. SupportedAbortSignalaligns with what is expected offetchin tests reflecting actual usage.