Skip to content

Commit 3b3d215

Browse files
author
Rob Figueiredo
committed
Promise.Then: Expand comment to point at PerformMicrotasksCheckpoint
1 parent 36874e7 commit 3b3d215

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

promise.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ func (p *Promise) Result() *Value {
8787
}
8888

8989
// Then invokes the given function when the promise has been fulfilled, not rejected.
90-
// The returned Promise resolves after the given function has finished execution.
90+
//
91+
// The returned Promise resolves after the callback finishes execution.
92+
//
93+
// V8 only invokes the callback when processing "microtasks".
94+
// The default MicrotaskPolicy processes them when the call depth decreases to 0.
95+
// Call (*Context).PerformMicrotaskCheckpoint to trigger it manually.
9196
func (p *Promise) Then(cb FunctionCallback) *Promise {
9297
p.ctx.register()
9398
defer p.ctx.deregister()
@@ -97,7 +102,7 @@ func (p *Promise) Then(cb FunctionCallback) *Promise {
97102
}
98103

99104
// Then2 invokes one of the given functions when the promise is fulfilled or rejected.
100-
// The returned Promise resolves after the callback has finished execution.
105+
// See Then for other details.
101106
func (p *Promise) Then2(onFulfilled, onRejected FunctionCallback) *Promise {
102107
p.ctx.register()
103108
defer p.ctx.deregister()
@@ -108,7 +113,7 @@ func (p *Promise) Then2(onFulfilled, onRejected FunctionCallback) *Promise {
108113
}
109114

110115
// Catch invokes the given function if the promise is rejected.
111-
// The returned Promise resolves after the callback has finished execution.
116+
// See Then for other details.
112117
func (p *Promise) Catch(cb FunctionCallback) *Promise {
113118
p.ctx.register()
114119
defer p.ctx.deregister()

0 commit comments

Comments
 (0)