mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.2k stars 22.49k forks source link

if a program goes in to infinite loop than . than i loose my code that i write in mdn javascript online editor . #2225

Closed amrishpatidar96 closed 3 years ago

amrishpatidar96 commented 3 years ago

because my computer memory get filled up by that infinite loop and browser say not responding . and there is not button in your editor for stopping it . so even it stuck in infinite loop we can stop the program. and over code persist in editor . there is reset button but in this case i loose whatever the code that i have written in editor.

Ryuno-Ki commented 3 years ago

Dear @amrishpatidar96,

we're sorry to hear this.

May I ask some clarifying questions?

  1. Does that happen on a specific page? Or do you have that on several pages?
  2. Were are you entering your code? Like, what do you mean by „javascript online editor”? (A screenshot is fine here also)
  3. Can you share the code that caused the infinite loop?

I'm thinking about how we could stop an infinite loop from happening …

amrishpatidar96 commented 3 years ago

Screenshot (8) after few minutes of running . nothing works on that component(online editor). Screenshot (9)

why do we not have button for handling such scenarios . because i use this editor while learning , to play with given examples on mdn website . so some time it happen that it does not stop like in my case. and whatever write from few minutes . i have to lose that code in that condition . let 's i can write the code again 20 to 25 line code is not big deal but it will not be a userfriendly . the website should not stuck and not become ir-responsive because of user action .

i am not advance developer but still i can tell you way to stop happening it . whenever user clicks on "run" button. and you can set a setTimeOut(handlingFunctionReference,10000) . and if it exceeds more than 10 seconds than you can show a popup and say that your program is taking too long "do you want to continue or stop" and if user clicks on stop you can stop it . and it will not get into infinite loop and also our page will not become irresponsive . because no one will write such a code that takes more time than 10 sec except settimeOut and timeRelated function . in this editor atleast . and if they write than we are showing popup or warning so still if they want to continue they can .

Ryuno-Ki commented 3 years ago

Ah, okay. So you're learning with an interactive example. That's cool!

The infinite-loop bug should likely be reported in https://github.com/mdn/interactive-examples/issues as well. I haven't looked into how they set up the execution.

avivmu commented 3 years ago

It was discussed and they decided it's not worth implementing something to tackle this

Ryuno-Ki commented 3 years ago

Thanks for the link, @avivmu. I'm closing this as Won't Fix then. I'm sorry, @amrishpatidar96