Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not send continue events #307

Merged
merged 1 commit into from
Sep 21, 2018
Merged

Conversation

jonyo
Copy link
Contributor

@jonyo jonyo commented Sep 19, 2018

…f the normal flow

This fixes #301

Note: there is still the problem that it will seem to "hang" when you continue and the PHP code takes a while to run, #308 will fix that.

@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #307 into master will decrease coverage by 0.11%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #307      +/-   ##
==========================================
- Coverage   70.17%   70.05%   -0.12%     
==========================================
  Files           5        5              
  Lines        1016     1012       -4     
  Branches      161      161              
==========================================
- Hits          713      709       -4     
  Misses        303      303
Impacted Files Coverage Δ
src/phpDebug.ts 66.8% <ø> (-0.14%) ⬇️
src/xdebugConnection.ts 84.53% <ø> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fa2d28...105643e. Read the comment docs.

@@ -279,10 +279,6 @@ class PhpDebugSession extends vscode.DebugSession {
})
connection.on('error', disposeConnection)
connection.on('close', disposeConnection)
connection.on('before-execute-command', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this event then still used at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixfbecker No, this PR completely removes the event, it turns out that it causes problems to send the continued event. In several scenarios it duplicates other events sent that also tell vscode that the code is running. The second notice sometimes gets sent after it is paused again, and ends up making vsc think it continued when it is actually still paused.

@@ -679,11 +679,6 @@ export class Connection extends DbgpConnection {
const data = iconv.encode(commandString, ENCODING)
this._pendingCommands.set(transactionId, command)
this._pendingExecuteCommand = command.isExecuteCommand
if (this._pendingExecuteCommand) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixfbecker The flag itself is still used to prevent that deadlock where it waits for breakpoint init call on a connection that is hung running code.

Copy link
Contributor

@felixfbecker felixfbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #301 you said

I think the "opposite" problem is happening now which is worse than the original problem that it fixes, now instead of looking like it is paused when it is not, it looks like the code continued when it did not. So like I said above I'll try to come up with a solution that will allow neither to happen, but if I do not make progress today I'll put that PR in place since the old problem is not as bad.

Could you explain in what case before-execute-command gets fired when the program is not actually continuing?

@jonyo
Copy link
Contributor Author

jonyo commented Sep 21, 2018

@felixfbecker It helps to see the description for that event:

From https://github.com/Microsoft/vscode-debugadapter-node/blob/f479e3dc97796cecaebccf455707cd4b5a4c0ad1/protocol/src/debugProtocol.ts#L107-L111

	/** Event message for 'continued' event type.
		The event indicates that the execution of the debuggee has continued.
		Please note: a debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. 'launch' or 'continue'.
		It is only necessary to send a 'continued' event if there was no previous request that implied this.
	*/

So in other words, if there is somewhere that we are making the code continue that is not part of a continue request from vscode, that is when to use it. One thing that comes to mind is if the code has paused somewhere that we ignore and we want to continue automatically, we might want to then notify vscode that it has continued.

My original statement was before I fully looked into it. It would be more accurate to say that we send the continued event in addition to the normal response to vscode, and sometimes that can cause vscode to think the code is running when it is actually paused. One example of when this could happen: it sends as a result of initializing xdebug as part of the first run command. It sends that continued event. That event is sent async. It could actually get to a breakpoint and be paused on the breakpoint at the time vscode receives the event, so vscode incorrectly thinks the code has continued when it has not. That is what was happening on #301 I hope that makes sense?

@felixfbecker
Copy link
Contributor

Ah, that makes sense to me.

@felixfbecker felixfbecker changed the title fix(phpDebug,xdebugConnection): Do not send continue events outside o… fix: do not send continue events Sep 21, 2018
@felixfbecker felixfbecker merged commit 047777b into xdebug:master Sep 21, 2018
@felixfbecker
Copy link
Contributor

🎉 This PR is included in version 1.12.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

towhidabsar pushed a commit to towhidabsar/vscode-php-debug that referenced this pull request Apr 29, 2019
A debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. 'launch' or 'continue'.
It is only necessary to send a 'continued' event if there was no previous request that implied this.

Note: there is still the problem that it will seem to "hang" when you continue and the PHP code takes a while to run, xdebug#308 will fix that.

Fixes xdebug#301
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug context lost on multiple connections
2 participants