From 85bc805f4f7375445839a7509a6d3df51a6ddb01 Mon Sep 17 00:00:00 2001 From: Aldwin Vlasblom Date: Fri, 10 Nov 2017 15:28:20 +0100 Subject: [PATCH] Add "then" to strings which may be used elsewhere The massive adoption of Promises made many programs potentially vulnerable to "accidental Promises". In short, a program might take user input and produce an object as such: ```js { [userInput]: AnyFunction } ``` ...when the object above is given to a Promise, nothing breaks until the user input is exactly `"then"`. Once it's *then*, a Promise will assume that the object as another Promise, and in trying to assimilate this accidental Promise the function will be called. After that, one of three things will happen 1. The function calls one of the continuations provided by the Promise, and the program continues with some unexpected data (this is highly unlikely) 1. The program hangs and never terminates (if the function stores input in memory) 1. The program terminates early, failing to execute any other chained Promises (the more likely case) For more in-depth information, please refer to the appropriate sections in the articles I've written regarding this issue: 1. [Broken Promises - Specialized API](https://medium.com/@avaq/broken-promises-2ae92780f33#6828) 1. [A clarification with examples to the article above](https://medium.com/@avaq/im-referring-to-the-fact-that-a-promise-is-eagerly-evaluated-as-opposed-to-lazily-evaluated-5385cc519e3b#33cd) (see the part under "I never found myself creating an object with a then method") --- blns.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/blns.txt b/blns.txt index bcc73fb..d4db0cc 100644 --- a/blns.txt +++ b/blns.txt @@ -17,6 +17,7 @@ TRUE FALSE None hasOwnProperty +then \ \\