File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -369,8 +369,8 @@ void CaptureStackTraces(const FunctionCallbackInfo<Value> &args) {
369369
370370 std::vector<ThreadResult> results;
371371
372+ std::vector<std::future<ThreadResult>> futures;
372373 {
373- std::vector<std::future<ThreadResult>> futures;
374374 std::lock_guard<std::mutex> lock (threads_mutex);
375375 for (auto &thread : threads) {
376376 auto thread_isolate = thread.first ;
@@ -393,10 +393,13 @@ void CaptureStackTraces(const FunctionCallbackInfo<Value> &args) {
393393 },
394394 std::cref (thread_info.async_store )));
395395 }
396+ }
396397
397- for (auto &fut : futures) {
398- results.emplace_back (fut.get ());
399- }
398+ // Wait for all futures to complete AFTER releasing the lock
399+ // to avoid deadlock with ThreadPoll trying to acquire the same mutex
400+ // https://github.com/getsentry/sentry-javascript-node-native-stacktrace/issues/35
401+ for (auto &fut : futures) {
402+ results.emplace_back (fut.get ());
400403 }
401404
402405 auto current_context = capture_from_isolate->GetCurrentContext ();
You can’t perform that action at this time.
0 commit comments