denoland / denoland/deploy_feedback

508: Loop Detected (LOOP_DETECTED) Recursive requests to the same deployment cannot be processed.

Open
#575 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
79
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Hello I'm having some problems when deploying a script that locally was working perfectly.
Since I needed some [Vercel AI utiliities](https://github.com/vercel/ai) to deal with OpenAI streaming API which only works on Node.js, I had to set up an external worker on cloudflare that takes care of the streaming.
This is my workflow:

Deno api endpoint **/generate**
```javascript
if (pathname === "/generate") {
//call to node server
const call = await fetch("https://generate.jeieufbe43.workers.dev/", {
method: "POST",
body: JSON.stringify(request),
});
//proxy response body back to client for streaming
return new Response(call.body, { status: 200 });
}
```

The cloudflare worker will make the request to OpenAI, stream the response back to Deno and finally it needs to save the generation on Deno database so it will send a fetch request to a Deno api endpoint **/saveposts**)

```javascript

if (pathname === "/saveposts" && _req.method === "POST") {
try {
const res = JSON.parse(await _req.json()); // Parse JSON body
const articles = res.news;
for (const article of articles) {
const articleKey = ["articles", ulid()];
// Set the article with its unique key
await kv.set(articleKey, article);
}
return new Response(JSON.stringify(articles), {
status: 200,
});
} catch (error) {
console.log("error", error);
return new Response(error, { status: 500 });
}
}
```

Now for some reasons this request to deno server fails with this error:
508: Loop Detected (LOOP_DETECTED) Recursive requests to the same deployment cannot be processed.

Why is this perceived as a loop while it isn't? Shouldn't this error be triggered with at least 2 or 3 more callbacks?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.