Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: src/js/harmony-async-await.js

Issue 2334323006: Fix async/await memory leak (Closed)
Patch Set: fix typo Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/harmony-async-await.js
diff --git a/src/js/harmony-async-await.js b/src/js/harmony-async-await.js
index 4109b77fb54174366cdae648b0dae7fc0c5b02af..761c554455f55bee5f4e705379ae3cdcb02cc962 100644
--- a/src/js/harmony-async-await.js
+++ b/src/js/harmony-async-await.js
@@ -64,10 +64,22 @@ function AsyncFunctionAwait(generator, awaited, mark) {
// );
var promise = PromiseCastResolved(awaited);
- var onFulfilled =
- (sentValue) => %_Call(AsyncFunctionNext, generator, sentValue);
- var onRejected =
- (sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
+ var onFulfilled = sentValue => {
+ %_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 => {
+ %_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;
+ }
if (mark && DEBUG_IS_ACTIVE && IsPromise(awaited)) {
// Mark the reject handler callback such that it does not influence
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698