Skip to content

Commit 6b219ef

Browse files
committed
src: only block on user blocking worker tasks
Previously, we block on all worker tasks in the main thread, which can cause a deadlock if the worker task post another foreground task and wait for it to complete. This patch changes it to only block on worker tasks that have kUserBlocking priority to avoid the deadlock. In addition this updates the task queue to be a priority queue and order the task based on priority, so that higher priority tasks get executed first, as the documentation suggests.
1 parent 68cc1c9 commit 6b219ef

File tree

4 files changed

+246
-69
lines changed

4 files changed

+246
-69
lines changed

src/api/environment.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,8 @@ std::unique_ptr<MultiIsolatePlatform> MultiIsolatePlatform::Create(
598598
int thread_pool_size,
599599
v8::TracingController* tracing_controller,
600600
v8::PageAllocator* page_allocator) {
601-
return std::make_unique<NodePlatform>(thread_pool_size,
602-
tracing_controller,
603-
page_allocator);
601+
return std::make_unique<NodePlatform>(
602+
thread_pool_size, tracing_controller, page_allocator);
604603
}
605604

606605
MaybeLocal<Object> GetPerContextExports(Local<Context> context,

src/debug_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void NODE_EXTERN_PRIVATE FWrite(FILE* file, const std::string& str);
5555
V(MKSNAPSHOT) \
5656
V(SNAPSHOT_SERDES) \
5757
V(PERMISSION_MODEL) \
58+
V(PLATFORM) \
5859
V(QUIC)
5960

6061
enum class DebugCategory : unsigned int {

0 commit comments

Comments
 (0)