Index: src/js/harmony-async-await.js |
diff --git a/src/js/harmony-async-await.js b/src/js/harmony-async-await.js |
index 0d470bbe8c84300dfcd9213ba1becb016294bd40..a7934abec0d173fea2dab8f87ecdaff7d45a5a11 100644 |
--- a/src/js/harmony-async-await.js |
+++ b/src/js/harmony-async-await.js |
@@ -67,10 +67,22 @@ function AsyncFunctionAwait(generator, awaited, outerPromise) { |
// ); |
var promise = PromiseCastResolved(awaited); |
- var onFulfilled = |
- (sentValue) => %_Call(AsyncFunctionNext, generator, sentValue); |
- var onRejected = |
- (sentError) => %_Call(AsyncFunctionThrow, generator, sentError); |
+ var onFulfilled = (sentValue) => { |
adamk
2016/09/15 22:43:20
Nit: no need for parens while you're changing this
Dan Ehrenberg
2016/09/16 00:36:01
Done
|
+ %_Call(AsyncFunctionNext, generator, sentValue); |
+ // The resulting Promise is a throwaway, so it doesn't matter what it |
+ // resolves to. What is important is that we don't end up keeping the |
+ // whole chain of intermediate Promises alive by returning the value |
+ // of AsyncFunctionNext, as that would create a memory leak. |
+ return; |
+ }; |
+ var onRejected = (sentError) => { |
adamk
2016/09/15 22:43:20
ditto
Dan Ehrenberg
2016/09/16 00:36:00
Done
|
+ %_Call(AsyncFunctionThrow, generator, sentError); |
+ // Similarly, returning the huge Promise here would cause a long |
+ // resolution chain to find what the exception to throw is, and |
+ // create a similar memory leak, and it does not matter what |
+ // sort of rejection this intermediate Promise becomes. |
+ return; |
+ } |
// Just forwarding the exception, so no debugEvent for throwawayCapability |
var throwawayCapability = NewPromiseCapability(GlobalPromise, false); |