mdn / mdn/content

CPU bound promise operation with generatePrimes

Open
#42,715 0 comments 1 reaction 0 assignees View on GitHub
Content:Learn:JavaScript
Dominant language
Markdown
Stars
11k
Forks
23.2k
Avg merge
2d 9h
Merged PRs (30d)
331

Description

### MDN URL

https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Async_JS/Introducing

### What specific section or headline is this issue about?

The trouble with long-running synchronous functions

### What information was incorrect, unhelpful, or incomplete?

The section "[The trouble with long-running synchronous functions](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Async_JS/Introducing#the_trouble_with_long-running_synchronous_functions)" is concluded by suggesting that async programming will solve this type of specific problem.

The issue is that it suggests that a CPU bound operation like generating primes will run concurrently if put into a promise, misleading programmers. CPU bound operations like this will still run synchronously even if promises are used.

I've actually made this mistake before thinking it would make calculations faster, only to see it run the same or slower with promises.

### What did you expect to see?

The difference between CPU bound and non bound tasks should described and why promises/async programming cannot solve CPU bound problems. It should note that workers should be the solution for that and using promises for CPU bound tasks will still run them synchronously.

It should have a section about when to use workers vs async and how I/O based operations work better with async functions.

### Do you have any supporting links, references, or citations?

[**https://stackoverflow.com/questions/868568/what-do-the-terms-cpu-bound-and-i-o-bound-mean**](https://www.baeldung.com/cs/cpu-io-bound)

### Do you have anything more you want to share?

_No response_

### MDN metadata

Page report details

* Folder: `en-us/learn_web_development/extensions/async_js/introducing`
* MDN URL: https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Async_JS/Introducing
* GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/learn_web_development/extensions/async_js/introducing/index.md
* Last commit: https://github.com/mdn/content/commit/0cc63ce1d7f43eb98746a908a9aba68ef6a36f7b
* Document last modified: 2025-08-26T12:44:08.000Z

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.