Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "then" to strings which may be used elsewhere #159

Merged
merged 1 commit into from
May 24, 2018

Commits on Nov 10, 2017

  1. 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")
    Avaq authored Nov 10, 2017
    Configuration menu
    Copy the full SHA
    85bc805 View commit details
    Browse the repository at this point in the history