Error: Cannot perform I/O on behalf of a different request

Hi Everyone I have a project where i'm using sveltekit but i had a problem where when clicking back or forward in the browser is causing internal error 500? after i get the internal error 500 i try to refresh (ctrl + r) it went normal. I have 2 webapps that have this issues, and weirdly its happening in the production build that i already deploy in the cloudflare pages, dev and local build environment is fine. i see the logs and i got
Error: Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance.
Error: Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance.
11 Replies
alka_99
alka_994mo ago
bump. this only happening in cloudflare pages. logs is attached anyone can help? looking at log i get error
Error: Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance.
Error: Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance.
Cyb3r-Jak3
Cyb3r-Jak34mo ago
That typically means a request was in the global scope was tried to be handled by a different request
alka_99
alka_994mo ago
do you have any idea where i should start debugging then? I'm new in programming world
Cyb3r-Jak3
Cyb3r-Jak34mo ago
Can you share what your code looks like?
alka_99
alka_994mo ago
i can deploy it in stackblitz give me a moment
Cyb3r-Jak3
Cyb3r-Jak34mo ago
That error typically means that sveltekit is doing something that it shouldn't be so might be worth asking that community as well
alka_99
alka_994mo ago
@Cyb3r-Jok3 i also asking sveltekit community, but i haven't get any feedback yet
Cyb3r-Jak3
Cyb3r-Jak34mo ago
I am seeing
[Error: Cannot subscribe to 'page' store on the server outside of a Svelte component, as it is bound to the current request via component context. This prevents state from leaking between users.For more information, see https://kit.svelte.dev/docs/state-management#avoid-shared-state-on-the-server]
[Error: Cannot subscribe to 'page' store on the server outside of a Svelte component, as it is bound to the current request via component context. This prevents state from leaking between users.For more information, see https://kit.svelte.dev/docs/state-management#avoid-shared-state-on-the-server]
Seems similar to the cloudflare error
alka_99
alka_994mo ago
i think that's different error it is state management for sveltekit, i might miss that one
Cyb3r-Jak3
Cyb3r-Jak34mo ago
Ah only thing I could think of with it. Don't know Svelte well so hopefully someone who does will know what the cause is
alka_99
alka_994mo ago
@Cyb3r-Jok3 thank you for your hands :MeowHeartCloudflare: i didn't get with the global scope can you elaborate more? @Cyb3r-Jok3 bump.