colorette icon indicating copy to clipboard operation
colorette copied to clipboard

fix: remove recursion in replaceClose to prevent stack overflow(#106)

Open Delagen opened this issue 10 months ago • 13 comments

Delagen avatar Feb 19 '25 11:02 Delagen

@jorgebucaran Can you approve it and publish? I have some issues with it in my CI, because output seems too large for recurse implementation

Delagen avatar Feb 19 '25 11:02 Delagen

Thanks, let me take a look and get back to you. I'm in the middle of a busy week.

jorgebucaran avatar Feb 19 '25 12:02 jorgebucaran

@jorgebucaran Any plans on this week? )

Delagen avatar Feb 24 '25 12:02 Delagen

Hey, sorry for the delay again. Frankly, I'd be more curious to see exactly how this package is being used to cause a stack overflow first before discarding a well-tested, inmutable, and elegant implementation in favor of an imperative one. I'd just like to see more research go into it.

jorgebucaran avatar Feb 27 '25 08:02 jorgebucaran

Hey, sorry for the delay again. Frankly, I'd be more curious to see exactly how this package is being used to cause a stack overflow first before discarding a well-tested, inmutable, and elegant implementation in favor of an imperative one. I'd just like to see more research go into it.

It's used in webpack-dev-server or something linked to output log.

So when log is massive this recursive implementation just produce stack overflow.

I think simple string replace should not use recursion

Delagen avatar Feb 27 '25 09:02 Delagen

That's helpful to know. But it might also depend on how the log function is implemented. I'll try to look into it soon. Maybe we can offer an alternative that's still recursive or immutable, without affecting performance.

jorgebucaran avatar Feb 27 '25 11:02 jorgebucaran

If program can call stack overflow on small data doesn't matter if code written immutable or not.

Why do you call function with accumulator mutable?

Delagen avatar Feb 27 '25 20:02 Delagen

I think I might be able to find a similar solution or alternative. I'll let you know.

jorgebucaran avatar Feb 28 '25 02:02 jorgebucaran

Am facing this issue when i try to switch from angular 15 to 16

JosephNgabo avatar Mar 10 '25 11:03 JosephNgabo

I am also facing the same issue when migrating from Angular 18 to 19

davidfervisma avatar Jun 10 '25 10:06 davidfervisma

Also faced this error. In my case I'm not migrating app, just implementing workspaces (monorepo) on existing Angular 18.2.7 app. Node.js V22.15.0

jakubkirylo avatar Jun 10 '25 10:06 jakubkirylo

fwiw, i too just ran into the max stack error in colorette while upgrading angular. the pr above with a proposed fix definitely solved the issue for me.

johnwest80 avatar Sep 09 '25 16:09 johnwest80

Any update on this? I'm facing the same error when trying to migrate my TSLint setup to ESLint setup. We already did Angular upgrade a while back to version 19 which went smoothly.

nasif25 avatar Nov 04 '25 21:11 nasif25