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 20 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

Copy link

cypress bot commented Feb 18, 2025

cypress    Run #60484

Run Properties:  status check passed Passed #60484  •  git commit e4ec76cfa2: attempt to fix v8 snapshots
Project cypress
Branch Review refactor/axios/create-instance
Run status status check passed Passed #60484
Run duration 18m 00s
Commit git commit e4ec76cfa2: attempt to fix v8 snapshots
Committer Ryan Manuel
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 9
Tests that did not run due to a developer annotating a test with .skip  Pending 1099
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 26546
View all changes introduced in this branch ↗︎
UI Coverage  45.83%
  Untested elements 190  
  Tested elements 165  
Accessibility  92.54%
  Failed rules  3 critical   8 serious   2 moderate   2 minor
  Failed elements 888  

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.

2 participants