Javascript should not continue executing upon a page refresh.
Reported by
mats.ahl...@gmail.com,
Oct 15 2017
|
||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.52 Safari/537.36
Steps to reproduce the problem:
<script>
while(true) {
debugger;
// program logic goes here
}
</script>
Refresh the page while the debugger is open.
What is the expected behavior?
Page refreshes immediately.
What went wrong?
Code continues execution forever.
In a large program, sometimes one might accidentally cause an infinite loop, or (more commonly) the remaining javascript to execute may be extremely large. As a developer, the expected behavior when refreshing the page is that the script will halt execution and the page will refresh. Indeed this is the case if one halted on a throw statement.
However on a console.assert, or on a debugger statement, usually it is the case that when hitting ctrl-R or the refresh button or revisiting the URL, the script will resume where it was 'paused', executing the "rest of the program" -- potentially many seconds if not minutes (or an infinite loop) of useless code one did not want to execute. This will continue until the code has finished executing or the user kills the process. Only then will the page refresh.
This makes it very difficult sometimes to test code without being very careful. Also it makes no sense to execute potentially unbounded amounts of computation before a page refresh.
Thus there are two issues:
1) In the example, one cannot even open the devtools, because the page will hang indefinitely when opened.
2) Once one is a state where one can debug the code in devtools, refreshing the page will cause an infinite loop or an unbounded large amount of unnecessary computation.
If there is some spec or technical reason that javascript must continue execution upon a page refresh, then it would be very nice to have a "Force Refresh" shortcut that would automatically force-refresh the page, halting and destroying if necessary any pending things.
This has been referenced in https://stackoverflow.com/questions/13134723/how-to-terminate-script-execution-when-debugging-in-google-chrome (the current solution is "open the task manager, find the process but not the devtools process, and manually kill it, then perform a refresh; another solution is to create a reference error or similar bug on-the-fly in the console).
Did this work before? No
Chrome version: 62.0.3202.52 Channel: beta
OS Version: 6.3
Flash Version: Shockwave Flash 27.0 r0
,
Oct 16 2017
,
Oct 17 2017
@Reporter: Could you please provide a sample test file or URL for ease of reproducing and further triaging from TE end. Thanks!
,
Oct 17 2017
,
Sep 27
You can use terminate execution to terminate any JavaScript execution: https://twitter.com/ak_239/status/979767841573359618 Most likely we need to do it automatically on refresh / force refresh.
,
Sep 27
|
||||
►
Sign in to add a comment |
||||
Comment 1 by mats.ahl...@gmail.com
, Oct 15 2017