Skip to content

Commit 3b54b9a

Browse files
committed
set empty context_frame_, issue a process warning
1 parent c458399 commit 3b54b9a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/async_wrap.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include "env-inl.h"
2626
#include "node_errors.h"
2727
#include "node_external_reference.h"
28+
#ifdef DEBUG
29+
#include <node_process-inl.h>
30+
#endif
2831
#include "tracing/traced_value.h"
2932
#include "util-inl.h"
3033

@@ -338,8 +341,7 @@ void AsyncWrap::EmitDestroy(bool from_gc) {
338341
HandleScope handle_scope(env()->isolate());
339342
USE(object()->Set(env()->context(), env()->resource_symbol(), object()));
340343
}
341-
Isolate* isolate = env()->isolate();
342-
context_frame_.Reset(isolate, Undefined(isolate));
344+
context_frame_.Reset();
343345
}
344346
}
345347

@@ -663,7 +665,14 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
663665
Local<Value>* argv) {
664666
EmitTraceEventBefore();
665667

666-
DCHECK(!context_frame_.IsEmpty());
668+
#ifdef DEBUG
669+
if (context_frame_.IsEmpty()) {
670+
ProcessEmitWarning(env(),
671+
"MakeCallback() called without context_frame, "
672+
"likely use after destroy of AsyncWrap.");
673+
}
674+
#endif
675+
667676
ProviderType provider = provider_type();
668677
async_context context { get_async_id(), get_trigger_async_id() };
669678
MaybeLocal<Value> ret =

0 commit comments

Comments
 (0)