Skip to content

Commit a8c96c8

Browse files
committed
New async stack trace logic
1 parent c3634e2 commit a8c96c8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Source/JavaScriptCore/interpreter/Interpreter.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,21 @@ void Interpreter::getStackTrace(JSCell* owner, Vector<StackFrame>& results, size
664664
#endif
665665

666666
if (Options::useAsyncStackTrace()) {
667+
#if USE(BUN_JSC_ADDITIONS)
668+
// After the loop, check the last EntryFrame if we haven't found a generator yet.
669+
// This is necessary for environments like Bun where the microtask execution
670+
// (e.g., drainMicrotasks) doesn't appear as a frame on the stack, so we never
671+
// cross an EntryFrame boundary during the loop.
672+
if (!asyncStackTraceOriginGenerator && previousEntryFrame) {
673+
auto* record = vmEntryRecord(previousEntryFrame);
674+
if (record->m_context) {
675+
if (auto* generator = jsDynamicCast<JSGenerator*>(record->m_context)) {
676+
asyncStackTraceOriginGenerator = generator;
677+
asyncStackTraceInsertPos = previousEntryFrameStackTraceInsertPos;
678+
}
679+
}
680+
}
681+
#endif
667682
if (asyncStackTraceOriginGenerator) {
668683
Vector<StackFrame> asyncFrames;
669684
getAsyncStackTrace(owner, asyncFrames, asyncStackTraceOriginGenerator, maxStackSize);

0 commit comments

Comments
 (0)