Description
I'm seeing this warning in my project:
[error] ... The global execution context in Scala.js is based on JS Promises (microtasks).
[error] Using it may prevent macrotasks (I/O, timers, UI rendering) from running reliably.
[error]
[error] Unfortunately, there is no way with ECMAScript only to implement a performant
[error] macrotask execution context (and hence Scala.js core does not contain one).
[error]
[error] We recommend you use: https://github.com/scala-js/scala-js-macrotask-executor
[error] Please refer to the README.md of that project for more details regarding
[error] microtask vs. macrotask execution contexts.
[error]
[error] If you do not care about macrotask fairness, you can silence this warning by:
[error] - Adding @nowarn("cat=other") (Scala >= 2.13.x only)
[error] - Setting the -P:scalajs:nowarnGlobalExecutionContext compiler option (Scala < 3.x.y only)
[error] - Using scala.scalajs.concurrent.JSExecutionContext.queue
[error] (the implementation of ExecutionContext.global in Scala.js) directly.
[error]
[error] If you do not care about performance, you can use
[error] scala.scalajs.concurrent.QueueExecutionContext.timeouts().
[error] It is based on setTimeout which makes it fair but slow (due to clamping).
[error]
[error] Future(1).map { x =>
[error] ^
I understand the intent, or why usage of scala.concurrent.ExecutionContext.global
may be problematic, however it's a standard import that often gets used for code that cross-compiles to both the JVM and JS, which is one of the primary strengths of Scala.js. Having the official compiler perpetually warn on standard functionality, and suggest a third-party library, isn't good IMO. And why isn't that warning and option available on Scala 3.x?
Personally, I see only 3 possibilities:
- Fix
global
in Scala.js proper; - Deprecate
global
and remove it completely in a future version; - Leave it as is, and remove the warning;
As it is, removing that warning is a lot of work, especially in a project that compiles for multiple Scala versions. Updating minor Scala.js versions shouldn't be this hard.
Just a suggestion, thanks a lot for your work 🤗