Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: begin to use axios for cloud api requests #31041

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

cacieprins
Copy link
Contributor

@cacieprins cacieprins commented Feb 6, 2025

  • Closes

Additional details

As a first step in removing @cypress/request, this shifts the API call to create an instance to Axios.

  • Because of how we modify dependencies in situ for v8 snapshots, Axios needed to be patched. This patch forces Axios into server-mode.
  • Logging is handled as an Axios middleware
  • Error transforms are handled as an Axios middleware. To aid with DRY, this function is defined in such a way as to be used with older API request definitions.
  • createInstance is moved to its own file and isolated from the statefulness of the main api/index.ts file
  • Type definitions are introduced for the request initiator, to aid with typescript migrations
  • retries are handled with the asyncRetry util. axios-retry was considered, but the additional package size and complications regarding overriding behavior for POSTs made it untimely.
  • Additional tests were introduced for the middleware. The existing integration tests suffice for this refactor. More closely unit testing this module in isolation is rather difficult with the test harness in @packages/server, but should be considered a TODO if we migrate to vitest.

Note: while this request is a POST, and POSTs are not typically retry-able, this endpoint is now idempotent. Retries are enabled in order to improve resiliency to network splits, etc.

Steps to test

How has the user experience changed?

PR Tasks

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.

1 participant