Skip to content

Conversation

@krystofwoldrich
Copy link

@krystofwoldrich krystofwoldrich commented Nov 7, 2025

Why

I was running into the following error when using the Snack SDK in CF Workers.

I've tracked down the issue to an old node-fetch.

Error on server: TypeError: Cannot read properties of null (reading 'has')
    at processHeader (node-internal:internal_http_outgoing:904:39)
    at ClientRequest._storeHeader (node-internal:internal_http_outgoing:209:21)
    at ClientRequest._implicitHeader (node-internal:internal_http_client:414:14)
    at ClientRequest.#write (node-internal:internal_http_outgoing:823:18)
    at ClientRequest.write (node-internal:internal_http_outgoing:607:32)
    at ClientRequest.write (node-internal:internal_http_client:382:22)
    at writeToStream (snack-sdk.js:10347:10)
    at snack-sdk.js:10688:5
    at new Promise (<anonymous>)
    at fetch2 (snack-sdk.js:10493:10)

How

This PR removes the current ponyfill and defaults to global fetch impl of the runtime.

Since all modern browser have a solid fetch implementation, I think we could use the global for web. Likely we could do the same for Expo Apps.

For modern node ponyfill would also not be needed. But for other envs for example CF Workers, we need the ability to change the fetch function. So I exposed a public function setSnackSDKFetch(fn).

Test Plan

@krystofwoldrich krystofwoldrich changed the title chore: replace fetch ponyfill by node fetch chore: remove fetch ponyfill Nov 13, 2025
@krystofwoldrich krystofwoldrich force-pushed the @krystofwoldrich/upgrade-fetch branch from fd4e7d4 to ac0322b Compare November 13, 2025 00:14
@krystofwoldrich krystofwoldrich marked this pull request as ready for review November 13, 2025 00:15
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