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

Get VScode frontend debug configuration mapped correctly #1268

Merged
merged 7 commits into from
Jul 6, 2023

Conversation

tzjames
Copy link
Collaborator

@tzjames tzjames commented May 9, 2023

Features and Changes

Frontend breakpoints now work within VS code.
Only show the Debug Fullstack option as it is the most useful.

Testing

Set a breakpoint in the frontend. Hit the page containing the breakpoint and see it stop in VS code.

@github-actions
Copy link

github-actions bot commented May 19, 2023

Your preview environment pr-1268-bttf has been deployed.

Preview environment endpoints are available at:

@tzjames tzjames requested a review from tinahollygb July 4, 2023 15:16
@tinahollygb
Copy link
Contributor

This doesn't work for me (macOS).

image

I also get an alert that yarn doesn't exist but when the tasks execute, it looks like it's running fine.

image image

@tzjames
Copy link
Collaborator Author

tzjames commented Jul 6, 2023

@tinahollygb Thanks for running this on your machine! The output you posted was from the "Debug Next.js: server-side" terminal not the "Debug Back-end" terminal where the issue was happening. The former was using type "node-terminal" while the other was using "node" type. For whatever reason your environment seems to be missing the correct path for yarn when doing the "node" type. I assume you would just need to add node's path to your path in .zprofile and then it would have worked. However I found no difference in VScode behavior between using node and node-terminal, so no I changed them both to use node-terminal. So hopefully it works for you now without doing anything else.

Copy link
Contributor

@tinahollygb tinahollygb left a comment

Choose a reason for hiding this comment

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

I assume you would just need to add node's path to your path in .zprofile and then it would have worked.

node is already on my path. yarn is installed in /Users/tina/.nvm/versions/node/v16.14.2/bin/yarn and /Users/tina/.nvm/versions/node/v16.14.2/bin is on the path. This is configured in my ~/.zshrc. Are you sure it's that? I don't have any issues running from the terminal anywhere.

The change to node-terminal fixed it. I can break both on the backend code, and in the front-end with the sandboxed Chrome that pops up. The back-end one is helpful. The front-end one is somewhat helpful but it would be ideal to debug in an existing already-running Chrome instance, or point Chrome to it somehow. If this can be done it would be ideal so we can use the browser extensions we need (e.g. React DevTools, the GrowthBook chrome extension, etc.).

That said, this is good enough of a start.

@tzjames
Copy link
Collaborator Author

tzjames commented Jul 6, 2023

https://code.visualstudio.com/docs/nodejs/browser-debugging#_attaching-to-browsers So it runs the browser in debug mode with an argument that makes it use a different user profile. The good news though is that if you install extensions in that new browser then it will keep from one debug session to the next.

@tzjames tzjames merged commit c4b4606 into main Jul 6, 2023
3 checks passed
@tzjames tzjames deleted the ji/launch.json branch July 6, 2023 19:22
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.

None yet

2 participants