fix: circular references crashing the sdk #343
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.
🧰 What's being changed?
This resolves a problem in our handling of API definitions with a circular reference where instead of not leaving them alone, we were dereferencing them. This was causing us to end up with
[Circular]
JS references that couldn't be stringified into the API definition cache, resulting in a hard crash ofapi
.Fixes #313
🧬 Testing
See the test I added to
cache.test.js
.You can also test this with the definition @josei provided in #313:
You should see a
Response
dump with a 401 status code instead of:Note: If running the above code from within
packages/api
you may ned to clear your definition cache between these two manual tests -- you can do this withrm -rf node_modules/.cache
.