Skip to content

Conversation

@goto-bus-stop
Copy link
Member

This adds stack overflow protection to the existing "Variable Is Used" and "Fragment Is Used" validations, and the newly introduced subscription validation #963. Additionally, this significantly improves performance of the "Fragment Is Used" validation, which used to walk almost the entire document AST for each fragment definition, and now only does it once.

You need a lot of fragments to cause these to overflow, so it's only a problem for users who don't have a token limit configured or have it set much higher than the Router default.

@goto-bus-stop goto-bus-stop requested a review from a team as a code owner April 15, 2025 09:38

/// Track recursion depth to prevent stack overflow.
#[derive(Debug)]
struct DepthCounter {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct really is just an integer with extra steps, but I wanted to mimick the pattern that we have with RecursionStack in the other recursion-limited functions.

@goto-bus-stop goto-bus-stop merged commit ebe09fe into main Apr 18, 2025
12 checks passed
@goto-bus-stop goto-bus-stop deleted the renee/overflow-protection branch April 18, 2025 08:28
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

Successfully merging this pull request may close these issues.

2 participants