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

Error processing "attach" #18

Open dragonk233 opened 3 years ago

dragonk233 commented 3 years ago

i have used edge(edgehtml)and change to webview but still get the error

[vscode-debugger-extension-for-office-addins] Error processing "attach":connect ECONNREFUSED 127.0.0.1:9222

look forward to your kind reply

TCourtneyOwen commented 3 years ago

@dragonk233 Sorry to hear you are having problems with the extension. A couple questions for you:

Please let me know what you find.

Thanks,

Courtney

dragonk233 commented 3 years ago

Thank you for your prompt reply.

-this command did not worked so i try the other issue command. but the Error was still there

E:\officeAddIn1\UDF3>npx office-addin-dev-settings webview edge Error: ENOENT: no such file or directory, open 'E:\officeAddIn1\UDF3\edge'

E:\officeAddIn1\UDF3> E:\officeAddIn1\UDF3>npx office-addin-dev-settings webview .\manifest.xml edge The web view type is set to Edge.

TCourtneyOwen commented 3 years ago

Sorry I sent the wrong command, but you did end running the correct one after you added the manifest file path.

Are you about to browse to https://localhost:3000/taskpane.html?_host_Info=Excel$Win32$16.01$en-US$$$$0? I just want to be sure there is not an issue with your dev-server

dragonk233 commented 3 years ago

i can visit https://localhost:3000/taskpane.html?_host_Info=Excel$Win32$16.01$en-US$$$$0? correctly.

so i create a new project(Excel custom function) to provide some messages.

? Choose a project type: Excel Custom Functions Add-in project ? Choose a script type: JavaScript ? What do you want to name your add-in? UDF5


  Creating UDF5 add-in for Excel using JavaScript and Excel-functions at E:\officeAddIn1\UDF5

I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.

core-js@2.6.11 postinstall E:\officeAddIn1\UDF5\node_modules\core-js node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:

https://opencollective.com/core-js https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

core-js-pure@3.6.5 postinstall E:\officeAddIn1\UDF5\node_modules\core-js-pure node -e "try{require('./postinstall')}catch(e){}"

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})

added 989 packages from 565 contributors and audited 998 packages in 68.999s

40 packages are looking for funding run npm fund for details

found 26 vulnerabilities (22 low, 4 high) run npm audit fix to fix them, or npm audit for details

E:\officeAddIn1\UDF5>npm start

excel-custom-functions-js@2.0.0 start E:\officeAddIn1\UDF5 office-addin-debugging start manifest.xml

Debugging is being started... App type: desktop ? Allow localhost loopback for Microsoft Edge WebView? Yes Enabled debugging for add-in d0a272c5-66da-439c-90e8-f6b2b924118a. Debug method: 0 Starting the dev server... (webpack-dev-server --mode development) The dev server is running on port 3000. Process id: 4092 Sideloading the Office Add-in... Debugging started.

E:\officeAddIn1\UDF5>

TCourtneyOwen commented 3 years ago

Did you open the add-in taskpane before trying to attach the debugger? This is required, although it might not be spelled out clearly in the instructions.

-Courtney

dragonk233 commented 3 years ago

yes,i did it. the command of taskpane can run correctly.

sergeos commented 3 years ago

same problem with dragonk233

now, i'm change config to

{
      "name": "Excel Desktop (Edge Chromium)",
      "type": "edge",
      "request": "attach",
      "useWebView": "advanced",
      "port": 9222,
      "urlFilter": "https://localhost:3000/*",
      "timeout": 45000,
      "webRoot": "${workspaceFolder}",
      "preLaunchTask": "Debug: Excel Desktop",
      "postDebugTask": "Stop Debug"
    },

and debug is starting. But i can't catch any of my breakpoints in taskpane.ts.

p.s. is .ts files also supported or only .js?

TCourtneyOwen commented 3 years ago

Can you please try specifying a different port than 9222 in the launch.json config just in case that port might already be in use?

bradTeem commented 3 years ago

@TCourtneyOwen We are also experiencing this issue as well-- this is what we have tried so far: https://stackoverflow.com/questions/64705772/econnrefused-127-0-0-19222-when-trying-to-run-microsoft-office-add-in-debugger

I've tried some of the suggestions shown here in addition to the steps mentioned in the Stack Overflow question above, but no luck. In our case, we are trying to attach to an Outlook Web Add-In on Windows 10 version 1903.

This is the error that we get: [vscode-debugger-extension-for-office-addins] Error processing "attach": connect ECONNREFUSED 127.0.0.1:9222 Screen Shot 2020-11-12 at 2 31 39 PM

Any other ideas or suggestions to try?

TCourtneyOwen commented 3 years ago

@bradTeem just to clarify, are you running VS Code as admin? This is required.

Can you also try the following when you open your taskpane add-in:

[ { "description": "", "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9229/devtools/page/00469F37064ED88A0C667C5128A43AF7", "id": "00469F37064ED88A0C667C5128A43AF7", "title": "Contoso Task Pane Add-in", "type": "page", "url": "https://localhost:3000/taskpane.html?_host_Info=Excel$Win32$16.01$en-US$$$$0", "webSocketDebuggerUrl": "ws://localhost:9229/devtools/page/00469F37064ED88A0C667C5128A43AF7" } ]

Please let me know what you find.

Thanks,

Courtney

TCourtneyOwen commented 3 years ago

@bradTeem Another good way to ensure you are not running Edge Chromium is to check in your taskmanager. If you see a process called WWAHost.exe when your taskpane is open, then you are not running Edge Chromium and the debugger extension should work

sergeos commented 3 years ago

i'm use Microsoft Edge 86.0.622.68 based on Chromium. if browse this url: http://localhost:9222/json then i get:

}, {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/14A5CD311A110993D80FD379E12B1333",
   "id": "14A5CD311A110993D80FD379E12B1333",
   "title": "Contoso Task Pane Add-in",
   "type": "page",
   "url": "https://localhost:3000/taskpane.html",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/14A5CD311A110993D80FD379E12B1333"
}, {

And, when i'm starting addin: npm run start then getting this error: изображение

Web Addin is works, but i can't using VSCode debugger ( Can't catch any breakpoint line.

TCourtneyOwen commented 3 years ago

@sergeos If you are running Edge Chromium, the Office Add-in Debugger extension is not supported. However you can use the Debugger for Microsoft Edge extension, which does support Edge Chromium.

To use the Debugger for Microsoft Edge extension, please do the following:

Please give this a try and let me know how it goes.

Thanks,

Courtney

bradTeem commented 3 years ago

@TCourtneyOwen Thanks for your reply-- yes, VS Code is being run as Administrator.

When I tried accessing http://localhost:9229/json and https://localhost:9229/json, I get Can't reach this page in both Internet Explorer and Edge (the add-in still runs at https://localhost:4200, however).

After checking task manager, I do see WWAHost.exe is running the 'Details' tab: Screen Shot 2020-11-13 at 6 02 56 PM

My understanding from this SO question is that the web add-in on my version of Windows is running Internet Explorer. Is the VS Code Debugger Extension only compatible with pre-Chromium Edge? Or should I expect it to work with Internet Explorer as well?

-Brad

stevetfiligree commented 3 years ago

I have same problem with error Error [vscode-debugger-extension-for-office-addins] Error processing "attach": connect ECONNREFUSED 127.0.0.1:9222

I have followed the instructions to the letter. I recreated a fresh yeoman project, with Taskpane, react, typescript and same problem again.

TCourtneyOwen commented 3 years ago

@stevetfiligree Are you running VS Code as admin? Just want to be sure you are doing this required step

Thanks,

Courtney

stevetfiligree commented 3 years ago

Yes - did did not resolve it. I have tried on an unencrypted laptop and it works. I wonder if that is having an affect.

stevetfiligree commented 3 years ago

Ok I discovered my problem. I decided to try to reinstall yo and I go this error:

npm install yo generator-office -g

Troublshoot yo version Error: Couldn't find the 'yo' binary. Make sure it's installed and in your $PATH Troubleshoot: at notFoundError (C:\Users\Steven\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:8:11)

It was interesting because my username is NOT "Steven" but "Steven Lastname" Ie it should be trying to reference that here: (C:\Users\Steven Lastname\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:8:11)

I had been playing around with npm config to replace the space to a tilde, but it is what I think has led to this problem. Having a space in name just seems to create all kinds of problems on commandline with npm.

Solution

Create a new user account with no spaces in it. [Type into windows start menu] - accounts > [Click] Family and Users > Other Users - Add someone else to this PC > [Click] - I don't have this person's sign-in information > Add a user without a Microsoft account > [Type] NameWithNoSpaces

Obviously this is a pain having to reset a new user profile - but it works and it will resolve a lot of npm headaches going forward. Now it will create this folderspace:

Now looking at npmrc data

λ npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v14.15.1 win32 x64"

; builtin config undefined
prefix = "C:\\Users\\NameWithNoSpaces\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = c:\mylocationetc
; HOME = C:\Users\NameWithNoSpaces
; "npm config ls -l" to show all defaults.

Now installing yo and generator will work properly

npm install yo generator-office -g

Now the debug will work as advised by instruction.

Disclaimer:

TCourtneyOwen commented 3 years ago

@stevetfiligree Glad to hear things are working for you and perhaps you found a bug that the debugger extension is not working when the project has spaces in it. I will check that out after the holidays. I am officially on vacation now until the new year, so I won't be able to follow up until then.

The see the console logging, please add this to the debug config in launch.json:

"trace": "verbose"

Thanks,

Courtney

stevetfiligree commented 3 years ago

@TCourtneyOwen Thanks for reply Courtney. I have console.log before and after the default yeoman generated react app. It does nothing. I look in the following:

There is no generated console.log Not sure if there is something else I am missing. thanks

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "office-addin",
      "request": "attach",
      "name": "Attach to Office Add-ins",
      "port": 9222,
      "trace": "verbose",
      "url": "https://localhost:3000/taskpane.html?_host_Info=Excel$Win32$16.01$en-US$$$$0",
      "webRoot": "${workspaceFolder}",
      "timeout": 45000
      }
  ],
  "inputs": [
    {
      "id": "officeOnlineDocumentUrl",
      "type": "promptString",
      "description": "Please enter the url for the Office Online document."
    }
  ]
}

App.tsx

  click = async () => {
    try {
      await Excel.run(async context => {
        /**
         * Insert your Excel code here
         */
        const range = context.workbook.getSelectedRange();

        // Read the range address
        range.load("address");

        // Update the fill color
        range.format.fill.color = "yellow";

        console.log(123);
        await context.sync();
        console.log(`The range address was ${range.address}.`);
      });
    } catch (error) {
      console.error(error);
    }
  };

Also throw new Error('this is an error') does nothing either.

arttarawork commented 3 years ago

Thank you for your reply! I'll look into the launch configs and the App.tx to see how it replicates on our end.

aafvstam commented 3 years ago

I have same problem with error Error [vscode-debugger-extension-for-office-addins] Error processing "attach": connect ECONNREFUSED 127.0.0.1:9222

I have followed the instructions to the letter. I recreated a fresh yeoman project, with Taskpane, react, typescript and same problem again.

As you all ran into this issue I did some research in my weekly Live Stream and was 'lucky' to run into the same issue where I first was able to run it without issues.

image

I got it solved in the end and posted my solution on Stack Overflow here: Solution to Error ECONNREFUSED

Let me know if this works for you as well

TimMensch commented 3 years ago

OK, I'm seeing similar issues to the above.

I just enabled Trace as per above, and I get:

OS: win32 x64
Adapter node: v12.14.1 x64
vscode-chrome-debug-core: 3.23.11
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"office-addin","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true})
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}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"ClientRequest/initialize","data":{"Versions.DebugAdapterCore":"3.23.11","successful":"true","timeTakenInMilliseconds":"1.3004","requestType":"request"}}}
From client: attach({"name":"Word Desktop (Edge Legacy)","type":"office-addin","request":"attach","url":"https://localhost:3000/taskpane.html?_host_Info=Word$Win32$16.01$en-US$$$$0","port":9222,"timeout":600000,"trace":"verbose","webRoot":"D:\\projects\\LegalDocManager\\GeneratedProject","preLaunchTask":"Debug: Word Desktop","postDebugTask":"Stop Debug","__configurationTarget":5,"__sessionId":"184bfc45-2c18-400d-a060-1ad1a92432bb"})
Attaching to Edge
Launching adapter at with arguments:', {"0":{"name":"Word Desktop (Edge Legacy)","type":"office-addin","request":"attach","url":"https://localhost:3000/taskpane.html?_host_Info=Word$Win32$16.01$en-US$$$$0","port":9222,"timeout":600000,"trace":"verbose","webRoot":"D:\\projects\\LegalDocManager\\GeneratedProject","preLaunchTask":"Debug: Word Desktop","postDebugTask":"Stop Debug","__configurationTarget":5,"__sessionId":"184bfc45-2c18-400d-a060-1ad1a92432bb"}})
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"debugStarted","data":{"Versions.DebugAdapterCore":"3.23.11","request":"attach","args":["name","type","request","url","port","timeout","trace","webRoot","preLaunchTask","postDebugTask","__configurationTarget","__sessionId","sourceMapPathOverrides","sourceMaps"]}}}
Discovering targets via http://127.0.0.1:9222/json/list
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"targetCount","data":{"Versions.DebugAdapterCore":"3.23.11","numTargets":1}}}
Attaching to target: {"description":"WWAHost.exe","devtoolsFrontendUrl":"chrome-devtools://devtools/bundled/inspector.html?ws=127.0.0.1:9222/devtools/page/A205DA08-36FA-5E9F-0B41-0855E926AD","id":"A205DA08-36FA-5E9F-0B41-0855E926AD","title":"GeneratedProject","type":"page","url":"https://localhost:3000/taskpane.html?_host_Info=Word$Win32$16.01$en-US$$$$0","webSocketDebuggerUrl":"ws://127.0.0.1:9222/devtools/page/A205DA08-36FA-5E9F-0B41-0855E926AD"}
WebSocket Url: ws://127.0.0.1:9222/devtools/page/A205DA08-36FA-5E9F-0B41-0855E926AD
→ To target: "{\"id\":1,\"method\":\"Console.enable\"}"
→ To target: "{\"id\":2,\"method\":\"Debugger.enable\"}"
→ To target: "{\"id\":3,\"method\":\"Runtime.enable\"}"
→ To target: "{\"id\":4,\"method\":\"Runtime.runIfWaitingForDebugger\"}"
→ To target: "{\"id\":5,\"method\":\"Runtime.run\"}"

Looks like it should be working, but I'm running out of ideas of things to try. It just keeps spinning and never actually finishes attaching. After a minute it did dump:

To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"report-start-up-timings","data":{"Versions.DebugAdapterCore":"3.23.11","RequestedContentWasDetected":"timeout","Steps":"[\"BeforeFirstStep\",\"ClientRequest/initialize\",\"ClientRequest/attach\",\"Attach\",\"Attach.RequestDebuggerTargetsInformation\",\"Attach.ProcessDebuggerTargetsInformation\",\"Attach.AttachToTargetDebuggerWebsocket\",\"Attach.ConfigureDebuggingSession.Internal\",\"Attach.ConfigureDebuggingSession.Target\"]","All":"300016.0281","BeforeFirstStep":"[23.8069]","WaitingAfter.ClientRequest/initialize":"[25.053199]","ClientRequest/initialize":"[14.7595]","ClientRequest/attach":"[22.748701]","Attach":"[0.232201]","Attach.RequestDebuggerTargetsInformation":"[12.3727]","Attach.ProcessDebuggerTargetsInformation":"[0.7725]","Attach.AttachToTargetDebuggerWebsocket":"[1.326899]","Attach.ConfigureDebuggingSession.Internal":"[0.220999]","Attach.ConfigureDebuggingSession.Target":"[299939.5582]"}}}

...but still isn't attaching breakpoints.

Using the launch.json from the yo generator:

    {
      "name": "Word Desktop (Edge Legacy)",
      "type": "office-addin",
      "request": "attach",
      "url": "https://localhost:3000/taskpane.html?_host_Info=Word$Win32$16.01$en-US$$$$0",
      "port": 9222,
      "timeout": 600000,
      "trace": "verbose",
      "webRoot": "${workspaceRoot}",
      "preLaunchTask": "Debug: Word Desktop",
      "postDebugTask": "Stop Debug"
    }

Thoughts?

TimMensch commented 3 years ago

AND never mind.

A complete reboot later, it actually works.

Thoughts on what exactly might have been "stuck"? Would be nice to not have to reboot my debug system several times per day if I could just kill the right process(es). Now I at least have a workaround.

TCourtneyOwen commented 3 years ago

@TimMensch I too have run into similar problems and a reboot fixed it. Obviously not ideal. I would suggest killing all the Node processes and also the NetworkProxy.exe process if it is running. Sometimes this doesn't get terminated successfully.

-Courtney

MVSTeja91 commented 3 years ago

How to attack a debugger for Outlook Addin ?

juangburgos commented 2 years ago

https://user-images.githubusercontent.com/4707341/135094634-3533828c-fa15-46c8-92a4-bbab3079e0be.mp4

n1klaus commented 2 years ago

Any new solutions to the problem

Error [vscode-debugger-extension-for-office-addins] Error processing "attach": connect
ECONNREFUSED 127.0.0.1:9222

currently using visual studio 2022 on windows 10

millerds commented 2 years ago

Any new solutions to the problem

Error [vscode-debugger-extension-for-office-addins] Error processing "attach": connect
ECONNREFUSED 127.0.0.1:9222

currently using visual studio 2022 on windows 10

This is a plugin for "Visual Studio Code" not "Visual Studio".

If you are using VS Code then get the update for the plugin and see if it works for you.

n1klaus commented 2 years ago

i was looking for a workaround from same issue in VS2022

millerds commented 2 years ago

VS projects use a different setup (not webpack) and shouldn't be using this extension.