Skip to content

Commit

Permalink
Fix fetching module scripts with circular imports
Browse files Browse the repository at this point in the history
As pointed out by @jonco3 in IRC, the current fetching logic will
recurse infinitely if a module imports itself (directly or indirectly).
This fixes that by keeping track of all ancestors being fetched and not
re-fetching them.

Also, the "fetch a module script tree" and "fetch a single module
script" algorithms don't always complete with _new_ module scripts, if
they end up getting their result from the module map. So this removes
the word "new" in their preludes.
  • Loading branch information
domenic committed Feb 20, 2016
1 parent dc34d9f commit 3c047b5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -84318,10 +84318,13 @@ interface <dfn>NavigatorOnLine</dfn> {
</ol>

<p>To <dfn>fetch a module script tree</dfn> given a <var>url</var>, a <var>credentials mode</var>,
and a <var>settings object</var>, run these steps. The algorithm will asynchronously complete
with either null (on failure) or a new <span>module script</span> (on success).</p>
a <var>settings object</var>, and an optional <var>ancestor list</var>, run these steps. The
algorithm will asynchronously complete with either null (on failure) or a <span>module
script</span> (on success).</p>

<ol>
<li><p>If <var>ancestor list</var> is not given, let it be an empty list.</p></li>

<li><p><span>Fetch a single module script</span> given <var>url</var>, <var>credentials
mode</var>, and <var>settings object</var>.</p>

Expand All @@ -84333,16 +84336,17 @@ interface <dfn>NavigatorOnLine</dfn> {
these steps.</p></li>

<li><p>Otherwise, <var>result</var> is a <span>module script</span>. <span data-x="fetch the
descendants of a module script">Fetch the descendants</span> of <var>result</var>.</p></li>
descendants of a module script">Fetch the descendants</span> of <var>result</var> using an
ancestor list obtained by appending <var>url</var> to <var>ancestor list</var>.</p></li>

<li><p>When <span data-x="fetch the descendants of a module script">fetching the descendants of
a module script</span> asynchronously completes with <var>descendants result</var>,
asynchronously complete this algorithm with <var>descendants result</var>.</p></li>
</ol>

<p>To <dfn>fetch the descendants of a module script</dfn> <var>module script</var>, run these
steps. The algorithm will asynchronously complete with either null (on failure) or with
<var>module script</var> (on success).</p>
<p>To <dfn>fetch the descendants of a module script</dfn> <var>module script</var>, using a given
<var>ancestor list</var>, run these steps. The algorithm will asynchronously complete with either
null (on failure) or with <var>module script</var> (on success).</p>

<ol>
<li><p>Let <var>record</var> be <var>module script</var>'s <span
Expand Down Expand Up @@ -84373,15 +84377,16 @@ interface <dfn>NavigatorOnLine</dfn> {
</ol>
</li>

<li><p>Otherwise, add <var>url</var> to <var>urls</var>.</p></li>
<li><p>Otherwise, if <var>url</var> is not in <var>ancestor list</var>, add <var>url</var> to
<var>urls</var>.</p></li>
</ol>
</li>

<li>
<p>For each <var>url</var> in <var>urls</var>, <span>fetch a module script tree</span> given
<var>url</var>, <var>module script</var>'s <span
data-x="concept-module-script-credentials-mode">credentials mode</span>, and
<var>module script</var>'s <span>settings object</span>.</p>
data-x="concept-module-script-credentials-mode">credentials mode</span>, <var>module
script</var>'s <span>settings object</span>, and <var>ancestor list</var>.</p>

<p>If any of the <span>fetch a module script tree</span> invocations asynchronously complete
with null, the user agent may <span data-x="concept-fetch-terminate">terminate</span> any or
Expand All @@ -84395,7 +84400,7 @@ interface <dfn>NavigatorOnLine</dfn> {

<p>To <dfn>fetch a single module script</dfn>, given a <var>url</var>, a <var>credentials
mode</var>, and a <var>settings object</var>, run these steps. The algorithm will asynchronously
complete with either null (on failure) or a new <span>module script</span> (on success).</p>
complete with either null (on failure) or a <span>module script</span> (on success).</p>

<ol>
<li><p>Let <var>module map</var> be <var>settings</var>'s <span>module map</span>.</p></li>
Expand Down Expand Up @@ -116518,6 +116523,7 @@ INSERT INTERFACES HERE
John Stockton,
John-Mark Bell,
Johnny Stenback,
Jon Coppeard,
Jon Ferraiolo,
Jon Gibbins,
Jon Perlow,
Expand Down

0 comments on commit 3c047b5

Please sign in to comment.