Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
Event loop or CPU, which one block this?

example:

exports.products = (req, res) => {

  let el = 1;
  for (let i = 0; i < 100000000000000; i++) {
    el += i;
  }
  console.log(el);

  ...
  ...
  ...

  res.redirect('/');
};

If I add a loop like this between my code, which one will be block (Event loop or CPU) ?

When I run this my page stays on load for a long time to process code.

At the same time, the process list looks like:

enter image description here

The page stays clogged until this process is finished.

edit: When I do operations that do not run the same function from a separate browser, the page remains collapsed.

Now is this collapsing due to event loop blocking? Or is it because my processor doesn't have the power to spare for it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

JavaScript is a single threaded language. Any synchronous action is run on that thread via Event Loop. The loop process is running on that thread. So, when the loop is still ongoing JS is using the whole thread and after it finishes, CPU usage should come down.

Your CPU is fine but your code is blocking the main thread.

You can watch this amazing video describing how Event Loop works in JavaScript

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!