[ATA] Remove duplicate modules from getReferencesForModule#3391
[ATA] Remove duplicate modules from getReferencesForModule#3391jakebailey merged 1 commit intomicrosoft:v2from
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.
This is quadradic; how big are these inputs typically?
There was a problem hiding this comment.
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.
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.
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.
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).