tc39 / proposal-error-stacks

ECMAScript Proposal, specs, and reference implementation for Error.prototype.stack / System.getStack
https://tc39.github.io/proposal-error-stacks/
MIT License
168 stars 13 forks source link

Infinite loop in explainer page #29

Open erights opened 5 years ago

erights commented 5 years ago

https://github.com/tc39/proposal-error-stacks/blob/123ef01a1b706d68df12778dc936334eec0e0e75/spec.js#L298 says

  var current = this.$toc;
  var index = 0;
  while (index < path.length) {
    var children = current.children;
    for (var i = 0; i < children.length; i++) {
      if ('#' + path[index].id === children[i].children[1].getAttribute('href') ) {
         // ... update variable that might cause while loop to exit
      }      
    }
  }

In other words, if the if ('#'...) condition is false, none of current, index, or path are updated. The for loop always exits. The while loop never does.

This infinite loop causes the page to get stuck when viewed offline. For reasons I did not diagnose, it does not cause the page to get stuck when viewed on the web.

I suspect this problem does not come from this repository. If so, please refile at the appropriate place.

ljharb commented 5 years ago

This JS is generated by ecmarkup; but i can't fathom how viewing offline would affect anything - unless you're saying you were on the file:// protocol?

cc @bterlson

erights commented 5 years ago

Yes, I was going with file:

On Tue, Jun 18, 2019, 10:18 AM Jordan Harband notifications@github.com wrote:

This JS is generated by ecmarkup; but i can't fathom how viewing offline would affect anything - unless you're saying you were on the file:// protocol?

cc @bterlson https://github.com/bterlson

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tc39/proposal-error-stacks/issues/29?email_source=notifications&email_token=AACC3TADQJ24U3YVU7XW55TP3EKGFA5CNFSM4HYVUJUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX7K2PQ#issuecomment-503229758, or mute the thread https://github.com/notifications/unsubscribe-auth/AACC3TELW3N5OI6YHWO5YJLP3EKGFANCNFSM4HYVUJUA .

erights commented 5 years ago

s/going/viewing/

On Tue, Jun 18, 2019, 10:33 AM Mark S. Miller erights@gmail.com wrote:

Yes, I was going with file:

On Tue, Jun 18, 2019, 10:18 AM Jordan Harband notifications@github.com wrote:

This JS is generated by ecmarkup; but i can't fathom how viewing offline would affect anything - unless you're saying you were on the file:// protocol?

cc @bterlson https://github.com/bterlson

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tc39/proposal-error-stacks/issues/29?email_source=notifications&email_token=AACC3TADQJ24U3YVU7XW55TP3EKGFA5CNFSM4HYVUJUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX7K2PQ#issuecomment-503229758, or mute the thread https://github.com/notifications/unsubscribe-auth/AACC3TELW3N5OI6YHWO5YJLP3EKGFANCNFSM4HYVUJUA .

ljharb commented 5 years ago

Many web features are broken on file://; the typical advice i give is to never use it, and instead go with a local http server. That said, ecmarkup's JS certainly shouldn't infinite loop there :-/