sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Is it possible to debug SPFx projects in Visual Studio Codespaces using only a browser?

Open andrew-lott opened this issue 6 years ago • 9 comments

Category

  • [x] Question
  • [ ] Typo
  • [ ] Additional article idea

Question

Is it possible to debug an SPFx project in Visual Studio Codespaces using only a browser?

I have tried creating a new v1.11 web part project in my Codespace, which all works fine, I can gulp serve successfully, I've set up Port Forwarding for 4321, 5432 and 35729, but the workbenches fail to load.

I haven't had any luck with https even after exporting and installing the dev certificate, but disabling https in serve.json at least allows content to be served from localhost:4321 via port forwarding at https://[guid]-4321.app.online.visualstudio.com/. Navigating to /temp/workbench.html loads the file, but nothing displays as the page tries to load scripts etc from localhost:4321, not the port forwarding URL.

Attempting to use the hosted workbench at https://[domain].sharepoint.com/_layouts/15/workbench.aspx?debug=true&noredir=true&debugManifestsFile=https://[guid]-4321.app.online.visualstudio.com/temp/manifests.js also fails: TypeError: Cannot read property 'getManifests' of undefined, again because the manifests.js it loads, references content at localhost:4321 instead of the port forwarding URL. I've tried setting "hostname":"[guid]-4321.app.online.visualstudio.com" in my serve.json but this just causes gulp serve to fail: Error: listen EADDRNOTAVAIL: address not available.

There is a blog article claiming that SPFx in Codespaces should work except:

I used a local install of VSCode instead of the browser.

Environment details

  • Your Developer Environment: Windows 10
  • Target Environment: SharePoint Online
  • Framework: Node.js v10
  • Browser(s): Chrome v84/Chromium Edge v83
  • Tooling: Visual Studio Codespaces (Cloud-hosted codespace, no VS Code installed locally)

andrew-lott avatar Aug 13 '20 10:08 andrew-lott

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Aug 13 '20 10:08 msft-github-bot

https://www.schaeflein.net/using-visual-studio-codespaces-for-spfx-development/

andrewconnell avatar Aug 14 '20 20:08 andrewconnell

Thanks for your response @andrewconnell, however I linked to this article in my original post and crucially the author "used a local install of VSCode instead of the browser". I need to know if SPFx debugging in Visual Studio Codespaces entirely in a browser is possible?

This relies on port forwarding to access localhost on the cloud-hosted codespace, so I suspect the SPFx workbench page's/script's references to localhost would need to be configurable to make this work.

andrew-lott avatar Aug 15 '20 17:08 andrew-lott

Closing this issue as "answered". If you encounter a similar issue(s), please open up a new issue. See our wiki for more details: Issue-List: Our approach to closed issues

msft-github-bot avatar Aug 18 '20 18:08 msft-github-bot

Thanks, to expalin we have locked down laptops and can't run VS Code locally as a result.

sebastianrogers avatar Aug 20 '20 15:08 sebastianrogers

I'll leave it open, but IMHO, this isn't a SPFx question... it's more of a Codespaces question and will likely get better traction in whatever forum is best to ask questions about Codespaces.

Why? The workbench is just a locally hosted webserver hosted by Node.js. I haven't worked with VS Codespaces, but from the demos I saw, they showed this working. So... from my POV (unless I'm mistaken), there's nothing special about SPFx+Codespaces.

andrewconnell avatar Aug 20 '20 15:08 andrewconnell

Cross posted to here https://github.com/MicrosoftDocs/vscodespaces/issues/715

sebastianrogers avatar Aug 20 '20 15:08 sebastianrogers

Obsolete. Visual Studio Codespaces now retired.

andrew-lott avatar Oct 27 '21 11:10 andrew-lott

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

ghost avatar Nov 03 '21 12:11 ghost