Skip to content

fix(node): send Node requests through the shared Fetch transport - #46

Merged
roncodes merged 1 commit into
release/v2.1.0from
fix/node-adapter-requests
Oct 8, 2026
Merged

roncodes merged 1 commit into
release/v2.1.0from
fix/node-adapter-requests

Conversation

@roncodes

@roncodes roncodes commented Oct 8, 2026

Copy link
Copy Markdown
Member

Problem

In v2.0.0, NodeAdapter overrides request(method, url, options), but the inherited get() calls request(path, 'GET', {}, options). Under Node, every GET therefore went to <host>/<namespace>/GET, with the path sent as the HTTP method. NodeAdapter also read its constructor-time config, so headers added later with setHeaders (such as Customer-Token and Accept-Language) and host changes were dropped.

The existing test called each verb but didn't check the URL, method or headers, so it didn't catch this. Browsers and React Native use BrowserAdapter and were not affected. Node consumers were, and that includes the Storefront SDK once it depends on this package.

Fix

NodeAdapter now only adds its User-Agent header and inherits the browser Fetch transport. Every verb, the current host and namespace, and headers set later now behave the same as in BrowserAdapter.

Tests

  • New regression test: Node GET, POST and DELETE go to the right URL with the right method and body, and send the Authorization, setHeaders and per-request headers plus the Node User-Agent.
  • The test fails on main, with the GET going to https://api.test/v1/GET, and passes with this change.
  • 35/35 tests pass with 100% coverage. Typecheck, lint and format checks are clean.
  • Part of release/v2.1.0.

NodeAdapter overrode request() with (method, url) while the inherited get()
calls request(path, 'GET', ...), so every GET under Node went to '/<ns>/GET'
with the path as its method. It also read the constructor-time config, so
headers set later with setHeaders (Customer-Token, Accept-Language) and host
changes were dropped. NodeAdapter now only adds its User-Agent and inherits
the browser transport.
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b76e577) to head (8c4dc7f).
⚠️ Report is 1 commits behind head on release/v2.1.0.

Additional details and impacted files
@@               Coverage Diff                @@
##           release/v2.1.0       #46   +/-   ##
================================================
  Coverage          100.00%   100.00%           
================================================
  Files                  17        17           
  Lines                 866       855   -11     
  Branches              144       143    -1     
================================================
- Hits                  866       855   -11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@roncodes
roncodes merged commit 7ef9a0e into release/v2.1.0 Oct 8, 2026
39 of 41 checks passed
@roncodes
roncodes deleted the fix/node-adapter-requests branch October 8, 2026 09:53
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