Regex performance on typeResolver
We've been noticing that in our project, whenever we add a derived type (with Omit, Pick and so on), tsoa hangs or takes a long time to generate the specs.
While digging into it, I found out that the culprit was the contextualizedName method on typeResolver.ts. It contains a few Regexes with nested quantifiers. Depending on the type name, it can take up to a few minutes for each replace operation to finish.
Changing the method to use a regex with word boundaries, though, fixed the issue:
private contextualizedName(name: string): string {
return Object.entries(this.context).reduce((acc, [key, entry]) =>
acc.replace(new RegExp(`\\b(${key})\\b`, 'g'), `${entry.getText()}`), name);
}
If you're willing to try it I can open a PR. But right now we're still stuck with v5 because of a few duplicated typenames. I'd also like to open a PR for v5, but it doesn't seem there's a support branch on this repo. How should I proceed?
Anyways, thank you in advance and congratulations for the great work on tsoa!
Hello there pabloalvim 👋
Thank you for opening your very first issue in this project.
We will try to get back to you as soon as we can.👀
Hey @pabloalvim!
You're correct, contextualizedName was completely removed as of v6.0.0.
I'm not really a developer for TSOA (just here due to a separate issue), but maybe provide more details as to why you can't upgrade.. That sounds like a bigger issue.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days