-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ATA] Remove duplicate modules from getReferencesForModule #3391
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
Conversation
|
@microsoft-github-policy-service agree company="Google" |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://victorious-plant-05c166c10-3391.centralus.5.azurestaticapps.net |
| version, | ||
| } | ||
| }) | ||
| .filter((r, index, self) => self.findIndex(m => m.module === r.module && m.version === r.version) === index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quadradic; how big are these inputs typically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a scientific answer, but I would think most files don't import more than on the order of 10s of packages - but in the case of @modelcontextprotocol it is >1000. (I also don't think one would ever specify a different module versions for the same module? but just did the safest option for now, but happy to update) - I can also switch to a Set if preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you had said there were 1000s of calls; does that occur without 1000s of entries in this list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I updated my response (probably while you were responding, sorry about that), but I would not expect more than 10s of unique packages. So the array would not actually loop through 1000s of entries, but yes it can have 1000s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is just in a single file. Gotcha.
Why?
Go to the playground and try to use the following code:
Link
This can trigger 1000s of calls to jsdelivr because imports to zod are not de-duped, resulting in ERR_INSUFFICENT_RESOURCES errors.
This fix removes duplicate modules within the same file (they are already handled cross file).