Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 29e417c8d527b3d16e2fc1a97f631aafab5670b7..38d641dd99bfac3280f4b6185d74d44e2d9a042c 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -6461,10 +6461,12 @@ void Promise::Resolver::Reject(Local<Value> value) { |
} |
-MaybeLocal<Promise> Promise::Chain(Local<Context> context, |
- Local<Function> handler) { |
+namespace { |
+ |
+MaybeLocal<Promise> DoChain(Value* value, Local<Context> context, |
+ Local<Function> handler) { |
PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise); |
- auto self = Utils::OpenHandle(this); |
+ auto self = Utils::OpenHandle(value); |
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; |
i::Handle<i::Object> result; |
has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(), |
@@ -6474,10 +6476,18 @@ MaybeLocal<Promise> Promise::Chain(Local<Context> context, |
RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
} |
+} // namespace |
+ |
+ |
+MaybeLocal<Promise> Promise::Chain(Local<Context> context, |
+ Local<Function> handler) { |
+ return DoChain(this, context, handler); |
+} |
+ |
Local<Promise> Promise::Chain(Local<Function> handler) { |
auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
- RETURN_TO_LOCAL_UNCHECKED(Chain(context, handler), Promise); |
+ RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise); |
} |