Skip to content

Conversation

@EreMaijala
Copy link
Contributor

Move 'started' event after Xdebug settings have been set to make sure that 'run' is not executed before settings are processed and make sure that invalid settings don't prevent init from completing. Add some line feeds to output messages.

The main issue I stumbled on regularly was that because the 'started' event was emitted before the xdebugSettings from launch.json had been processed, occasionally the run command would be sent to Xdebug before the feature_set commands. When the feature_set commands were eventually sent, Xdebug was already in 'stopping' state and returned an error. This error was not caught and resulted in the vscode.InitializedEvent() being missed. This, in turn lead to a situation where the requests were displayed as running in the call stack window but got stuck without completing.

Move 'started' event after Xdebug settings have been set to make sure that 'run' is not executed before settings are processed and make sure that invalid settings don't prevent init from completing. Add some line feeds to output messages.
@EreMaijala
Copy link
Contributor Author

It's easy to test the feature_set problem also by adding an invalid setting to launch.json, like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "xdebugSettings": {
                "invalid": true
            },
            "log": false
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

@felixfbecker
Copy link
Contributor

make sure that invalid settings don't prevent init from completing

Unsure about this path. Why do you think is it okay to continue if the features failed? Why shouldn't we error the request (which should result in a toast vs just a log message)?

@codecov
Copy link

codecov bot commented Feb 23, 2018

Codecov Report

Merging #243 into master will decrease coverage by 0.25%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #243      +/-   ##
==========================================
- Coverage    69.6%   69.35%   -0.26%     
==========================================
  Files           5        5              
  Lines         987      992       +5     
  Branches      160      161       +1     
==========================================
+ Hits          687      688       +1     
- Misses        300      304       +4
Impacted Files Coverage Δ
src/phpDebug.ts 66.45% <33.33%> (-0.5%) ⬇️

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 ed1e32e...28022ca. Read the comment docs.

@EreMaijala
Copy link
Contributor Author

Since the settings are normally not critical for the debugger to work, I thought logging it in debug console would be better than aborting the whole process. I was also thinking that there might be other situations where setting an otherwise valid feature is not allowed for some reason beyond my knowledge, so it might be safer, but if you believe that raising a toast and erroring the request is better, I'd be fine with that too.

…better.

Send error responses instead of just shutting down so that e.g. EADDRINUSE caused by debugger being already active in another window doesn't result in an invalid state.
@EreMaijala
Copy link
Contributor Author

@felixfbecker I think this is the best I can do. The latest commit fixes startup problems e.g. when there's already a debugger running in another window and aborts the debugger if applying xdebugSettings fails. I couldn't find a way to display a nicer toast, though.

@EreMaijala
Copy link
Contributor Author

@felixfbecker Any chance of getting this merged?

@felixfbecker felixfbecker merged commit 4ee0783 into xdebug:master Apr 12, 2018
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.

2 participants