-
Notifications
You must be signed in to change notification settings - Fork 354
Fix chrome session restore promt in Windows #606
Conversation
src/chromeDebugAdapter.ts
Outdated
logger.log(`Killing Chrome process by pid: ${taskkillCmd}`); | ||
try { | ||
execSync(taskkillCmd); | ||
} catch (e) { | ||
// Can fail if Chrome was already open, and the process with _chromePID is gone. | ||
// Or if it already shut down for some reason. | ||
} | ||
if (!this._hasTerminated) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right way to check if the process is dead?
Are those other child processes just children of the main Chrome process, like Is the second taskkill definitely necessary? I am fine with just removing |
I'll do some more testing to verify that the child processes get cleaned up. The second task kill is not critical, but without it Chrome won't shut down in certain situations, for example if the web page prompts the user about unsaved changes. I feel like the expected behavior would be for us to kill Chrome anyway, without waiting for the user to answer the prompt. I'll see if the exit code gives me anything useful. |
Oh I see. Yeah I agree. |
@roblourens I have verified that all child processes are cleaned up, even without the Unfortunately, I think I'll just remove the |
In that case I think there's a very small chance that the PID would be recycled for a new process in the small slice of time between killing chrome with the first taskkill, and running the second. But I think it's very unlikely that it would happen that quickly. |
@roblourens I have updated this PR. However, Travis complains about errors in code that I did not touch. Also, if I do |
@roblourens can this PR be merged? Or do you want to see some change first? |
Sorry, the PR is good, I am just keeping master stable right now as we are working on shipping this in VS. @digeff @rakatyal I don't know whether to merge this now or wait for your release cycle to be done, to give it more verification time on the vscode side. It fixes https://github.com/Microsoft/vscode-chrome-debug/issues/416, do you see that issue when running in VS? If so, you are probably interested in this change, would appreciate if you try it out. |
@roblourens: We do see this issue in VS and would definitely like this to be fixed. We have to do an insertion later today in staging where we can verify if this works inside VS too. We don't ship till 2 more weeks so we have sufficient time to roll back just in case. So you can merge it in if this looks good to you. |
Ok, I'll merge it, let me know how it goes |
Fixes #416.
My first approach (call
continue()
before killing chrome) didn't work. Sometimes the issue happens even when the debugger isn't paused.My solution is to start by killing chrome more gracefully using
taskkill /PID ${this._chromePID}
. However this won't always kill chrome - if chrome prompts the user upon closing (e.g. viaonbeforeunload
), then chrome won't close. So in case the original kill command doesn't work, we send a follow-up command with the/F
parameter to force kill.If we end up needing to force kill, then the session restore bubble will sometimes still appear. But at least it happens much less frequently.
Note: I removed the
/T
parameter.taskkill /T /PID ${this._chromePID}
doesn't work - I get this console output:Apparently certain child processes can only be terminated with
/F
(possibly including the debugger process itself). But removing the/T
option works.