Node.js · Senior · Question 11 of 75

What is a typical cause of a slow regular expression blocking a Node.js server (ReDoS)?

/^(a+)+$/.test("aaaaaaaaaaaaaaaaaaaaaaaaaaaa!");

Explanation

Since the regex runs on the main thread, one request can freeze the whole server. Avoid nested quantifiers, limit input length, or use a linear-time engine like RE2.

Further reading

Problem with a question

Node.js · Senior · question 11

Test yourself

Take the Node.js · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz