Package
@storyblok/astro (Astro Integration)
Bug Description
When useStoryblokApi() is used in Astro SSR request paths running on Cloudflare Workers, navigation can eventually cause requests to hang and the Worker to fail. In testing, replacing those server-side useStoryblokApi() calls with plain fetch() calls to the Storyblok CDN endpoints stopped the crashes. The issue reproduces locally with astro dev + @astrojs/cloudflare and on a deployed Cloudflare Worker. It has been confirmed and replicated in both Chrome and Safari.
Steps to Reproduce
- Clone the repro project: https://github.com/nonsponsored/bug-astro-ssr-cloudflare-workers-storyblok
- Add a
.env file with:
STORYBLOK_API_KEY=<preview token>
STORYBLOK_API_VERSION=draft
STORYBLOK_REGION=<us or eu>
- Install dependencies and run the project:
npm install
npm run dev
- Open the repo in a browser.
- Repeat clicking back and forth between:
- Continue navigating until the Worker fails.
- Optionally repeat the same test on a deployed Cloudflare Worker build.
Expected Behavior
SSR navigation using useStoryblokApi() should continue to work without hanging, suspending the Worker, or throwing a runtime exception.
Actual Behavior
After repeated navigation, the Worker eventually fails. In the full application this could happen after roughly 5 navigations on content-heavy pages; in the minimal repro it can take around 20–30 clicks.
Observed failures include:
- Cloudflare Worker error:
The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response
- Cloudflare error page / Worker exception (
1101)
- In local dev, repeated
WebSocket is closed due to suspension messages and eventual request failure
Code Sample
Environment
System:
OS: macOS 15.7.4
CPU: (8) arm64 Apple M3
Memory: 94.33 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.22.1
npm: 10.9.4
pnpm: 10.28.1
Browsers:
Brave Browser: 146.1.88.136
Chrome: 146.0.7680.155
Firefox: 148.0.2
Safari: 26.3
Safari Technology Preview: 26.0
npmPackages:
@storyblok/astro: ^9.0.0 => 9.0.0
astro: ^6.0.8 => 6.0.8
Error Logs
Additional Context
No response
Package
@storyblok/astro (Astro Integration)
Bug Description
When
useStoryblokApi()is used in Astro SSR request paths running on Cloudflare Workers, navigation can eventually cause requests to hang and the Worker to fail. In testing, replacing those server-sideuseStoryblokApi()calls with plainfetch()calls to the Storyblok CDN endpoints stopped the crashes. The issue reproduces locally withastro dev+@astrojs/cloudflareand on a deployed Cloudflare Worker. It has been confirmed and replicated in both Chrome and Safari.Steps to Reproduce
.envfile with:STORYBLOK_API_KEY=<preview token>STORYBLOK_API_VERSION=draftSTORYBLOK_REGION=<us or eu>npm installnpm run dev/sdk-space/sdk-linksExpected Behavior
SSR navigation using useStoryblokApi() should continue to work without hanging, suspending the Worker, or throwing a runtime exception.
Actual Behavior
After repeated navigation, the Worker eventually fails. In the full application this could happen after roughly 5 navigations on content-heavy pages; in the minimal repro it can take around 20–30 clicks.
Observed failures include:
The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response1101)WebSocket is closed due to suspensionmessages and eventual request failureCode Sample
Environment
Error Logs
Additional Context
No response