Fixes an issue where the new Promise<T> implementation introduced in https://github.com/mrousavy/nitro/commit/8832bc5225353e9ac0905c9a51cc57bf3dc1f076 actually caused a thread-lock since std::future was still used. This caused the future to be awaited on the JS thread instead of the background thread, making promises resolve synchronously instead of asynchronously.
The issue was caused by std::future/std::shared_future's RAII mechanism where the destructor waits for the task to complete. Now, it is moved to a shared_ptr and only awaited for completion in the run function.
Fixes an issue where the new
Promise<T>
implementation introduced in https://github.com/mrousavy/nitro/commit/8832bc5225353e9ac0905c9a51cc57bf3dc1f076 actually caused a thread-lock sincestd::future
was still used. This caused thefuture
to be awaited on the JS thread instead of the background thread, making promises resolve synchronously instead of asynchronously.The issue was caused by
std::future
/std::shared_future
's RAII mechanism where the destructor waits for the task to complete. Now, it is moved to ashared_ptr
and only awaited for completion in the run function.