Post AxRIqHBVKsEVM7fVI0 by chris@mastodon.chriswiegman.com
 (DIR) More posts by chris@mastodon.chriswiegman.com
 (DIR) Post #AxQfUUUlGoQs3SISgK by aral@mastodon.ar.al
       2025-08-22T13:22:59Z
       
       0 likes, 0 repeats
       
       Today I learned that regular expressions have a size limit and you get a “regular expression too large” error if you go over it.Still trying to find some definitive documentation on what that size limit is in v8/latest Node.js.#web #dev #JavaScript #regularExpressions
       
 (DIR) Post #AxQgUnhlwrAPaT5tmS by inhji@chaos.social
       2025-08-22T13:34:12Z
       
       0 likes, 0 repeats
       
       @aral The obvious limit is your sanity 😝
       
 (DIR) Post #AxQhiWpZaC5rGFqvGi by peach@phpc.social
       2025-08-22T13:48:05Z
       
       0 likes, 0 repeats
       
       @aral
       
 (DIR) Post #AxQjeSocllfxYebAAK by chip@talking.dev
       2025-08-22T14:09:49Z
       
       0 likes, 0 repeats
       
       @aral It appears (in V8 at least) that there are two limits: one for the aggregate amount of space that all RegExps can take up on the heap of an isolate (https://github.com/v8/v8/blob/main/src/regexp/regexp.cc#L940-L955) and another for the size/depth when parsing. The former _seems_ to be 1MB for compiled and the latter at least has a test which fails at 20,000 "[1]"s but my quick looking didn't reveal a hard'n'fast limit (https://github.com/v8/v8/blob/main/test/mjsunit/regress/regress-1255368.js) I'm no v8 expert though, these may be useful pointers for where to dig
       
 (DIR) Post #AxQq2YseTGpb2jM8wq by obadafamily@mastodon.social
       2025-08-22T15:21:15Z
       
       0 likes, 0 repeats
       
       @aral We only need you to love and care. At the very least, share the pinned post. You may save a life. Thanks for your kindness
       
 (DIR) Post #AxRIjcn8bRwGLF6E6q by aral@mastodon.ar.al
       2025-08-22T20:42:53Z
       
       0 likes, 0 repeats
       
       @alex Hah, yeah, it was :)
       
 (DIR) Post #AxRIqHBVKsEVM7fVI0 by chris@mastodon.chriswiegman.com
       2025-08-22T15:17:49Z
       
       0 likes, 0 repeats
       
       @aral Oh my! I think I would hit my limit debugging that before any technical limit.
       
 (DIR) Post #AxRIqIb45KGzjgdQlk by aral@mastodon.ar.al
       2025-08-22T20:43:45Z
       
       0 likes, 0 repeats
       
       @chris Haha, it was dynamically generated :)
       
 (DIR) Post #AxRJAsErHMge4K3iJE by aral@mastodon.ar.al
       2025-08-22T20:47:33Z
       
       0 likes, 0 repeats
       
       @chip Thanks, Chip. I did dig around a bit and saw similar references.Bottom line: I really shouldn’t have been using a dynamically-generated regex for that part of the parser. Especially since I already have the start and end indices for the areas I want to replace. So I’m going to refactor with that approach.Appreciate your taking the time to look into it and reply :)
       
 (DIR) Post #AxUAcuRCNdtGss0KMy by dichotomiker@dresden.network
       2025-08-24T05:56:20Z
       
       0 likes, 0 repeats
       
       @aral I also learned, while being within bounds, the regex execution can run endless loops depending on its input string. 😩