<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - JSContext Promise resolve tasks too eager, can result in infinite loop"
   href="https://bugs.webkit.org/show_bug.cgi?id=151482">151482</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>JSContext Promise resolve tasks too eager, can result in infinite loop
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>JavaScriptCore
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>joepeck&#64;webkit.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>ggaren&#64;apple.com, keith_miller&#64;apple.com, mark.lam&#64;apple.com, utatane.tea&#64;gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>* SUMMARY
JSContext Promise resolve tasks too eager, can result in infinite loop.

Not sure if we should just treat this as behaves correctly or not. Technically this code does create an infinite loop of &quot;jobs&quot;, but it doesn't need to execute in such a 100% hang like it does.

* TEST
JSContext *context = [[JSContext alloc] init];
NSString *script = &#64;&quot;&quot;
    &quot;function makeAndResolvePromise() {\n&quot;
    &quot;   Promise.resolve(1).then(function() {\n&quot;
    &quot;       console.log('resolved');\n&quot;
    &quot;       makeAndResolvePromise();\n&quot; // Comment out this line to avoid infinite loop.
    &quot;   });\n&quot;
    &quot;};\n&quot;
    &quot;makeAndResolvePromise();&quot;;

NSLog(&#64;&quot;&gt;&gt;&gt; Before&quot;);
[context evaluateScript:script];
NSLog(&#64;&quot;&gt;&gt;&gt; After&quot;); // Never reached

* NOTES
- Promise.resolve.then will immediately queue a task to run the then callback at the end of this JS event loop (when the VM becomes idle)
  - that callback then runs and resolves a promise with a then callback, queued to run at the end of this JS event loop (when the VM becomes idle)
    - that callback then runs and resolves a promise with a then callback, queued to run at the end of this JS event loop (when the VM becomes idle)
      ...</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>