Skip to content

Conversation

ChaseMalik
Copy link
Contributor

Why?

Go to the playground and try to use the following code:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";

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).

@ChaseMalik
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Google"

@jakebailey jakebailey added the deploy-preview Enables automatic deployments to preview environments on a PR label May 21, 2025
Copy link
Contributor

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)
Copy link
Member

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?

Copy link
Contributor Author

@ChaseMalik ChaseMalik May 21, 2025

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

@jakebailey jakebailey merged commit 5e10fd0 into microsoft:v2 May 22, 2025
9 checks passed
@typescript-bot typescript-bot mentioned this pull request May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-preview Enables automatic deployments to preview environments on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants