OfficeDev / vscode-debugger-extension-for-office-addins

VS Code extension to allow for debugging Office Add-ins in VS Code
18 stars 7 forks source link

the debugger cannot be attached #27

Closed milancutlac closed 2 years ago

milancutlac commented 3 years ago

I followed the steps described to attach the debugger, and it does not want to start, I get ECONNREFUSED message: "[vscode-debugger-extension-for-office-addins] Error processing "attach": connect ECONNREFUSED 127.0.0.1:9222"

The json has the following configuration: { "type": "office-addin", "request": "attach", "name": "Attach to Office Add-ins", "port": 9222, "trace": "verbose", "url": "https://localhost:3000/taskpane.html?_host_Info=Word$Win32$16.01$en-US$$$$0", "webRoot": "${workspaceFolder}", "timeout": 45000 }

On https://localhost:3000 I have data loaded, so the dev server seems to work fine. This situation occurs for a brand new generated office addin.

Please advice. I am able to pay for the solution, if case. Thank you!

millerds commented 3 years ago

Can you tell me what browser versions you have installed?

milancutlac commented 3 years ago

Hey, it is the last edge version: 90.0.818.62

milancutlac commented 3 years ago

I've seen other people complaining about this but no solution worked.

millerds commented 3 years ago

There are a couple of different similar issues popping up (can't attach debugger), but they aren't all the same thing.

In this case the attach config in the instructions is outdate as it is for the earlier type of Edge browser (which is being deprecated by Windows updates) and not the chromium base Edge. Try changing the type to "edge" instead of "office-addin".

milancutlac commented 3 years ago

Thank you for help. I want to mention that I start visual studio code as admin (as always). Now I get the message:

Cannot connect to runtime process, timeout after 45000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9222).

And in the debug console:

2021-5-21, 07:33:05.094 UTC [07:33:05.096 UTC] OS: win32 x64 [07:33:05.099 UTC] Adapter node: v14.16.0 x64 [07:33:05.100 UTC] vscode-chrome-debug-core: 6.7.50 [07:33:05.101 UTC] debugger-for-edge: 1.0.15 [07:33:05.102 UTC] From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"msedge","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true}) [07:33:05.102 UTC] To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"exceptionBreakpointFilters":[{"label":"All Exceptions","filter":"all","default":false},{"label":"Uncaught Exceptions","filter":"uncaught","default":false}],"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsCompletionsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsRestartFrame":true,"supportsExceptionInfoRequest":true,"supportsDelayedStackTraceLoading":true,"supportsValueFormattingOptions":true,"supportsEvaluateForHovers":true,"supportsLoadedSourcesRequest":true,"supportsRestartRequest":true,"supportsSetExpression":true,"supportsLogPoints":true}} [07:33:05.102 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"ClientRequest/initialize","data":{"Versions.DebugAdapterCore":"6.7.50","Versions.DebugAdapter":"1.0.15","successful":"true","timeTakenInMilliseconds":"5.5669","requestType":"request"}}} [07:33:05.103 UTC] From client: attach({"type":"msedge","request":"attach","name":"Attach to Office Add-ins","port":9222,"trace":"verbose","url":"https://localhost:3000/taskpane.html?_host_Info=Word$Win32$16.01$en-US$$$$0","webRoot":"G:\\Luminos\\TCorpSWPlugin","timeout":45000,"__configurationTarget":5,"__sessionId":"785a774d-06c7-4e05-9d2c-3cb5ba43f1d1"}) [07:33:05.104 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"debugStarted","data":{"Versions.DebugAdapterCore":"6.7.50","Versions.DebugAdapter":"1.0.15","request":"attach","args":["type","request","name","port","trace","url","webRoot","timeout","configurationTarget","sessionId","pathMapping","sourceMaps","sourceMapPathOverrides","skipFileRegExps","targetFilter","smartStep","showAsyncStacks"]}}} [07:33:05.105 UTC] Getting browser and debug protocol version via http://127.0.0.1:9222/json/version [07:33:05.105 UTC] Discovering targets via http://127.0.0.1:9222/json/list [07:33:05.105 UTC] HTTP GET failed: Error: connect ECONNREFUSED 127.0.0.1:9222 [07:33:05.105 UTC] There was an error connecting to http://127.0.0.1:9222/json/version : connect ECONNREFUSED 127.0.0.1:9222 [07:33:05.106 UTC] HTTP GET failed: Error: connect ECONNREFUSED 127.0.0.1:9222 [07:33:05.106 UTC] Discovering targets via http://127.0.0.1:9222/json [07:33:05.108 UTC] HTTP GET failed: Error: connect ECONNREFUSED 127.0.0.1:9222

milancutlac commented 3 years ago

If I try to attach the debugger from the word addin taskpane, the DevTools opens for 5 seconds than it automatically closes. At first it worked. Also, within Microsoft Ede DevTools Preview app, the addin is not listed in the local sources, although this also worked and I was able to debug. The problems appeared after a windows update. The debugger from vs code never worked.

Thank you very much for your help.

millerds commented 3 years ago

Using the menu from the taskpane is one of the other issues I mentioned before. It's a crash happening and this the workaround:

  1. After running "npm start" open an Edge browser tab
  2. Type "edge://inspect" for the url and wait a few seconds after the page opens
  3. You should see a remote target section get populated with the add-in URL and a few links under it
  4. Click the 'inspect' link.

You should see the devtools load in a new window with a simulation of the live taskpane running office. The simulation is connected to the live pane and click it will trigger the same action in the live taskpane.

milancutlac commented 3 years ago

I really appreciate your help! I've downgraded to edge legacy and i am able to debug using microsoft edge devtools preview app. The debugger from the task pane is not available anymore now. But I've tried to follow your steps, and I have nothing in the "Remote target" section, it writes #LOCALHOST near it (not clickable). I don't know if is because of the downgrade, or if there is another cause.

The most frustrating thing is that the "native" debugger from within vs code is not working... Would it be possible to have a remote session whenever you are available, maybe you will see something I don't? I can pay for support if necessary.

If possible, then please write me at milan.cutlac@gmail.com Thanks!

millerds commented 3 years ago

I'll have to consider the call. For now, new project created using "yo office" should have debugging setup in VS Code for both legacy and chromium version of edge and you can look at those.

Note: I looked at the read me for the project and noticed it explicitly says Microsoft Edge (not chromium) is the prerequisite. Note sure why that or if it's accurate . . . but that is what it says.

tobiasdiez commented 3 years ago

I've exactly the same problem. ECONNREFUSED 127.0.0.1:9222, and nothing shown under "Remote target". I'm using Edge (legacy), so I don't think chromium is the problem.

Did you found a workaround in the meantime?

millerds commented 3 years ago

I believe the workaround I mentioned using "edge://inspect" is for the chromium version of edge instead of the legacy version.

millerds commented 2 years ago

Sorry . . . got side tracked with some other issues and features. The instruction here are correct for legacy Edge, but the stuff that goes in the launch.json file is different when it comes to chromium based Edge. To attach to chromium based Edge use this in launch.json:

{
  "name": "Attach to Office Add-in (Edge Chromium)",
  "type": "edge",
  "request": "attach",
  "useWebView": "advanced",
  "port": 9229,
  "timeout": 600000,
  "webRoot": "${workspaceRoot}",
  "trace": "verbose"
}
millerds commented 2 years ago

Also note that new projects generated from 'yo office' have all of this configuration information already in launch.json