Skip to content

refactor(shopify-assets): replace axios with fetch - #2261

Merged
pedrobonamin merged 3 commits into
mainfrom
cursor/shopify-assets-drop-axios-8924
Nov 2, 2026
Merged

pedrobonamin merged 3 commits into
mainfrom
cursor/shopify-assets-drop-axios-8924

Conversation

@pedrobonamin

@pedrobonamin pedrobonamin commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

sanity-plugin-shopify-assets only used axios for two plain GET requests to the Sanity Shopify assets endpoint. It has been there since the plugin's first commit in the original standalone repo. Nothing in the code depends on axios features: no interceptors, retries, upload progress, or Node-specific behavior.

Changes

  • Requests go through fromFetch from rxjs/fetch. rxjs is already a dependency, so no new package is added. withCredentials: true becomes credentials: 'include', and the bearer token header is unchanged.
  • axios rejects on non-2xx responses, but fetch doesn't. To keep the same behavior, the selector throws an Error that uses the API body's message, or Request failed with status code N when there is none. ShopifyAssetPicker now just reads err.message instead of err.response?.data?.message.
  • Side benefit: fromFetch aborts the in-flight request when switchMap moves on to a newer query. Before, axios inside defer kept the superseded request running even though its result was ignored.
  • axios is removed from the plugin's dependencies. The lockfile only loses this importer's entry. axios stays in the tree because @bynder/compact-view and others still use it. The lockfile was edited by hand on purpose: a plain pnpm install would also bump the Studio next overrides (see AGENTS.md). pnpm install --frozen-lockfile passes.

Unrelated cleanup

The search request no longer pipes through distinctUntilChanged(). This is mostly unrelated to the axios removal: the request emits a single value, so the operator never filtered anything, and that was already true with axios. It came up while reviewing this PR and is in its own commit, so it can be dropped or split out if preferred.

Tests

The existing regression test now stubs fetch instead of mocking axios. The mock is reset with mockReset() after each test, so an unused mockImplementationOnce can't leak into the next one. New tests cover:

  • the request URL, credentials: 'include' and the Authorization header
  • the error message taken from the API response body
  • the status-code fallback when the body has no message
  • aborting the superseded request

pnpm format, pnpm lint, pnpm knip, the plugin build and its Vitest suite all pass locally. The live Shopify endpoint wasn't exercised; that needs a project with Shopify connected.

Open in Web Open in Cursor 

Note

Low Risk
Scoped HTTP client swap in one plugin with preserved auth and error UX; behavior change is mainly aborting stale searches during rapid typing.

Reviewed by Cursor Bugbot for commit f0a1fce. Configure here.

@changeset-bot

changeset-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c017398

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

This PR includes changesets to release 1 package
Name Type
sanity-plugin-shopify-assets Patch

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

@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
plugins-studio Ready Ready Preview Nov 2, 2026 7:39am UTC
1 Skipped Deployment
Project Deployment Actions Updated
plugins-e2e-test-studio Ignored Ignored Nov 2, 2026 7:39am UTC

Request Review

@pedrobonamin pedrobonamin added the ✨ ai PR authored by an AI agent (🤖 bot is for CI automation/Renovate) label Oct 26, 2026 — with Cursor
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

✅ E2E Tests

🟢 45 passed • 🟡 1 flaky • view full report • view run

Studio: https://plugins-e2e-test-studio-mq2wj51we.sanity.dev

Datasets: pr-2261-chromium-41407503473, pr-2261-firefox-41407503473

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 38.96% 7913 / 20308
🔵 Statements 38.92% 8512 / 21868
🔵 Functions 34.49% 2160 / 6261
🔵 Branches 31.16% 4612 / 14797
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
plugins/sanity-plugin-shopify-assets/src/components/ShopifyAssetPicker.tsx 5.35% 0% 0% 6.12% 38-202
plugins/sanity-plugin-shopify-assets/src/datastores/shopify.ts 100% 83.33% 100% 100%
Generated in workflow #11488 for commit c017398 by the Vitest Coverage Report Action

@pedrobonamin
pedrobonamin marked this pull request as ready for review October 26, 2026 09:22
@pedrobonamin
pedrobonamin requested a review from a team as a code owner October 26, 2026 09:22
@pedrobonamin
pedrobonamin requested review from juice49 and removed request for a team October 26, 2026 09:22
cursoragent and others added 3 commits November 2, 2026 07:36
Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
mockClear keeps unconsumed mockImplementationOnce overrides, which would leak
into the next test. mockReset drops them and restores the default response.

Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
…etch

The fetch observable emits a single value, so distinctUntilChanged never filters anything.

Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
@pedrobonamin
pedrobonamin merged commit 854288a into main Nov 2, 2026
25 checks passed
@pedrobonamin
pedrobonamin deleted the cursor/shopify-assets-drop-axios-8924 branch November 2, 2026 13:18
@squiggler-app squiggler-app Bot mentioned this pull request Nov 2, 2026
pedrobonamin pushed a commit that referenced this pull request Nov 2, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## sanity-plugin-shopify-assets@2.1.1

### Patch Changes

- [#2261](#2261)
[`854288a`](854288a)
Thanks [@pedrobonamin](https://github.com/pedrobonamin)! - Replace
`axios` with the native `fetch` API. In-flight asset requests are now
aborted when a newer search supersedes them.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Release metadata only in this diff; the underlying change is a
localized HTTP client swap with request cancellation in the Shopify
assets plugin.
> 
> **Overview**
> This is a **Changesets release PR** that publishes
**sanity-plugin-shopify-assets@2.1.1** to npm. It bumps the package
version from `2.1.0` to `2.1.1`, adds the corresponding **CHANGELOG**
entry, and removes the consumed changeset file.
> 
> The release notes document the patch from
[#2261](#2261): Shopify asset
HTTP calls now use the **native `fetch` API** instead of **`axios`**,
and **in-flight requests are aborted** when a newer asset search
replaces them—reducing stale results and dropping the `axios` dependency
from the package.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
d6968b4. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: squiggler-app[bot] <265501495+squiggler-app[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview – plugins-studio — c0173984 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ ai PR authored by an AI agent (🤖 bot is for CI automation/Renovate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants