fix(algolia): use createFetchRequester so the SDK runs on CF Workers#68
Merged
Merged
Conversation
The algoliasearch v4 default requester loads node:http via the NodeHttpRequester, which crashes on first request in Cloudflare Workers (no node:http module). Pass `@algolia/requester-fetch` explicitly so every Deco runtime — Workers, Bun, Node 18+ — uses the global fetch. Without this, granadobr-tanstack's home ProductShelves silently swallowed the loader exception and rendered as empty skeletons even though credentials, init wiring, and the SDK construction all looked correct. requester-fetch declared as an optional peer dep with the same ^4 range as algoliasearch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🎉 This PR is included in version 2.7.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
algoliasearch v4 defaults to
NodeHttpRequester(usesnode:http) on server runtimes — which crashes on first request in Cloudflare Workers because thenode:httpmodule isn't available. Pass@algolia/requester-fetchexplicitly so the SDK uses the globalfetch, which is what every Deco target runtime (Workers, Bun, Node 18+) provides.Without this, granadobr-tanstack home ProductShelves silently swallowed the loader exception (CMS resolver chain catches errors and falls back to
undefined) and rendered as empty skeletons even though credentials, init wiring, and the SDK construction all looked correct from the outside.What changed
algolia/client.ts:algoliasearch(appId, key, { requester: createFetchRequester() })package.json:@algolia/requester-fetchdeclared as an optional peer dep with the same^4range asalgoliasearch. Added to devDeps for tests.14/14 tests pass.
Driving consumer
deco-sites/granadobr-tanstack worker: this was the root cause behind the 6 critical visual-regression issues on
/::mobilethat survived the apps-start#66/#67 wiring fix. Every algolia loader'sclient.search(...)threwCannot find module 'node:http'on CF Workers.Test plan
bun run typecheckcleanbunx vitest run algolia/— 14/14 pass🤖 Generated with Claude Code
Summary by cubic
Ensure the Algolia client works on Cloudflare Workers by using a fetch-based requester instead of Node’s HTTP. Fixes crashes in loaders and restores rendering across Workers, Bun, and modern Node.
Bug Fixes
algoliasearchto use@algolia/requester-fetchviacreateFetchRequester()to avoid thenode:httpdependency in Workers.requester) is passed.Dependencies
@algolia/requester-fetchas an optional peer (^4) and dev dependency.Written for commit d556ae5. Summary will update on new commits.