New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 774852 link

Starred by 4 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

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
 
As a more practical use-case, consider reproducing by placing a debugger statement somewhere in a page that does a large amount of computation (in the middle of that computation).

Alternatively, consider a subtle infinite loop caused by mutual recursion in a large program.


Perhaps also a debugger statement should (at least for developers) open the devtools and pause execution (rather than be ignored) when the page is opened.
Labels: Needs-Triage-M62
Cc: vamshi.k...@techmahindra.com
Labels: Triaged-ET Needs-Feedback
@Reporter: Could you please provide a sample test file or URL for ease of reproducing and further triaging from TE end. 

Thanks!

Comment 4 by caseq@chromium.org, Oct 17 2017

Components: -Platform>DevTools Platform>DevTools>JavaScript
Labels: -Needs-Feedback
Owner: kozy@chromium.org
Status: Assigned (was: Unconfirmed)
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.
Cc: kozy@chromium.org
 Issue 849370  has been merged into this issue.

Sign in to add a comment