Skip to content

Comments

fix(fetch): use current global fetch instead of cached one when env f…#2

Open
MitchLewis930 wants to merge 1 commit intopr_022_beforefrom
pr_022_after
Open

fix(fetch): use current global fetch instead of cached one when env f…#2
MitchLewis930 wants to merge 1 commit intopr_022_beforefrom
pr_022_after

Conversation

@MitchLewis930
Copy link

@MitchLewis930 MitchLewis930 commented Jan 30, 2026

PR_022


Note

Low Risk
Small behavior change scoped to the fetch adapter’s selection of fetch when env overrides are absent; low risk but could affect environments relying on prior caching semantics.

Overview
Ensures the fetch adapter uses the current global fetch implementation when config.env.fetch is not provided/undefined, instead of relying on a previously cached reference.

This updates factory() to merge env defaults without capturing fetch, selects _fetch = envFetch || fetch at request time, and adjusts getFetch() seeding so env merging doesn’t cache a global fetch. Adds a unit test that monkey-patches global fetch and verifies the adapter picks up the new implementation.

Written by Cursor Bugbot for commit cf78825. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

skipUndefined: true
}, globalFetchAPI, config ? config.env : null);

let env = config ? config.env : {};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeError when config.env is undefined in getFetch

High Severity

The expression config ? config.env : {} evaluates to undefined when config exists but lacks an env property. Since getFetch(config) is called from adapters.js with the full request config (which normally doesn't include env), destructuring undefined on the next line throws a TypeError. The original code used utils.merge which safely handles undefined arguments.

Fix in Cursor Fix in Web

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