Skip to content

[EOCI-745] prevent recursive range error on redirects#190

Merged
evanheisler merged 1 commit intomasterfrom
EOCI-745-prevent-recursion
Sep 16, 2025
Merged

[EOCI-745] prevent recursive range error on redirects#190
evanheisler merged 1 commit intomasterfrom
EOCI-745-prevent-recursion

Conversation

@evanheisler
Copy link
Contributor

@evanheisler evanheisler commented Sep 16, 2025

graphql-proxy-service will sometimes error with a RangeError: Maximum call stack size exceeded. The log's call stack points to an infinite recursive loop within the @lifeomic/alpha client's request method.

The errors occur in the chat agent callstack from various user-agents but its very difficult to tell why. (logs). Bugsnag is reporting these as 502's from flma, but from the logs we can see its not limited to the member app.

Looking back in the logs and matching up dates with changes, it also may have started after introducing thinking mode.

Reviewing the code, the conclusion is that the client is receiving a 301 or 302 response, causing it to re-call itself with the same parameters, leading to the crash. The specific flaw is that the client does not have a safeguard to detect when a redirect points back to the original URL.

The logic now checks if the resolved redirect URL is identical to the original request URL. If they are the same, the redirect chain is immediately broken, and the response is returned to the caller.

This should replace the crash with a non-fatal application error (the returned 302 response). This makes the system stable and allows for safe investigation into which downstream service is issuing the redirect.

@xdumaine
Copy link
Contributor

I'm missing the connection between thinking mode and 302 response code - what's that?

@evanheisler
Copy link
Contributor Author

I'm missing the connection between thinking mode and 302 response code - what's that?

Just highlighting it because the timing was suspicious and might spark an idea. The first occurrence I found of this particular error was on 7/31 just after think mode was deployed.

@evanheisler
Copy link
Contributor Author

evanheisler commented Sep 16, 2025

To be clear, this change isn't really a fix for whats causing the error, but should cause gql-proxy to resolve (instead of getting stuck on the request) and attempt to use createPost and give a more useful error.

@evanheisler evanheisler merged commit ee57cea into master Sep 16, 2025
6 checks passed
@evanheisler evanheisler deleted the EOCI-745-prevent-recursion branch September 16, 2025 22:04
@github-actions
Copy link

🎉 This PR is included in version 7.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants