Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackAssertionError: Failed to send request - INFINITE_LOOP_DETECTED #319

Open
hrmoller opened this issue Oct 23, 2024 · 3 comments
Open
Assignees

Comments

@hrmoller
Copy link

I'm seeing the below error quite a bit in the logs on Vercel but don't see it locally at all.

I have not tracked it down to what part of my own code that provokes this error to happen but will post here when/if I track it down. However, I have the following code in my middleware.ts and I suspect that to be the place that triggers the error below.

I'm not making any direct calls to /api/v1/users/me but I call await stackServerApp.getUser() a lot of places in my application.

Versions
"@stackframe/stack": "^2.6.12"
"next": "14.2.15"

Error

StackAssertionError: Failed to send request to https://api.stack-auth.com/api/v1/users/me: 508 Infinite loop detected

INFINITE_LOOP_DETECTED


This is likely an error in Stack. Please make sure you are running the newest version and report it.
    at (node_modules/@stackframe/stack-shared/dist/interface/clientInterface.js:260:0)
    at (node_modules/@stackframe/stack-shared/dist/utils/results.js:122:0)
    at (node_modules/@stackframe/stack-shared/dist/interface/clientInterface.js:72:0)
    at (node_modules/@stackframe/stack-shared/dist/interface/clientInterface.js:135:0)
    at (node_modules/@stackframe/stack-shared/dist/interface/serverInterface.js:12:0)
    at (node_modules/@stackframe/stack-shared/dist/interface/serverInterface.js:22:25)
    at (node_modules/@stackframe/stack-shared/dist/interface/serverInterface.js:44:0)
    at (node_modules/@stackframe/stack/dist/esm/lib/stack-app.js:1264:0)
    at (node_modules/@stackframe/stack/dist/esm/lib/stack-app.js:120:0)
    at (node_modules/@stackframe/stack-shared/dist/utils/caches.js:43:0)
@hrmoller
Copy link
Author

Disabling the authcheck in middleware.ts does not prevent the error from happening.

@vermashobhit1994
Copy link

I've used chatgpt tool and find out to add below code in below path
stack\packages\stack-shared\src\interface\clientInterface.ts

here add below code

// Handle loop detection (508 status code) before processing other responses
if (rawRes.status === 508) {
  return Result.error(new KnownErrors.LoopDetected(508, "Infinite loop detected in request chain"));
}

before statement

const processedRes = await this._processResponse(rawRes);

@fomalhautb fomalhautb self-assigned this Nov 12, 2024
@N2D4 N2D4 self-assigned this Nov 13, 2024
@fomalhautb fomalhautb removed their assignment Nov 13, 2024
@fomalhautb
Copy link
Contributor

We have spent hours looking into this problem and still haven't figured out why. It seems like this only happened on Vercel starting recently and has no negative effect except for the error log. We will continue to investigate, but for now, you can probably just ignore this error.

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

No branches or pull requests

4 participants