Skip to content

Regression with fetch in service worker (1.12.2) #7153

@jonesmac

Description

@jonesmac

Describe the bug

This change here removes the global fetch as part of the globalFetchAPI.

That's fine for initial load because export const getFetch = (config) => { on line 264 will pass an undefined config and make env = {} which will safely destructure.

However, when making a request, getFetch is called from an adapter (not on static load), and it has a config however config.env is undefined. That causes line 266 to throw because config is defined, but .env is not so you get a destructiing error.

To Reproduce

See Codesandbox where fetch is forced as the default and errors - https://codesandbox.io/p/sandbox/6z72dh

Expected behavior

It should support environments where fetch is the only option.

Axios Version

1.12.2

Adapter Version

fetch

Browser

all

Browser Version

any

Node.js Version

latest

OS

all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions