fix: Fix tokenizer hitting tail-recursion limit #125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
TypeScript also has a tail recursion limit and the changes in #111, while being very effective at reduing parsing overhead times, caused us to now hit the limit of 1,000 when too many ignored tokens were being tokenized.
This PR addresses this by splitting the recursion of ignored tokens back out, reducing the iteration count of tokens for each chain of ignored tokens back to
1
.That does mean that we still have a limit of 1,000 tokens, including chains of ignored tokens, but from preliminary testing it looks like this is quite reasonable and hard to hit in an app with composed fragments.
I actually like that this may cause us to have a hard limit on which queries are reasonably parsed with
gql.tada
, and when hitting this limit, there's a high chance of a fragment boundary being missed.Set of changes
skipIgnored
type alias to tokenizertakeSelectionRec
type