question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

breakpoints in client side javascript not hit in express project

See original GitHub issue

Environment (please complete the following information):

  • OS (e.g., Windows 10):macOS 12.1
  • Extension version (e.g., 1.2.3): v1.4.5

Describe the bug:

I set a break point in a self invoking anonymous function and it was not hit.

Repro steps:

  1. use npx express-generator --no-view to create an express static site
  2. cd into the new project directory
  3. execute npm install
  4. launch the express server DEBUG=bug-express:* npm start
  5. Generate a launch.json file with the standard launch edge and open dev tools configuration.
  6. update configuration url entry to http://localhost:3000/
  7. While in the launch.json file add an edge launch configuration and update the url for that too.
  8. Add a script block to the projects default index.html file:
<script>
  (function () {
    console.log("not going to work")
  })()
</script>
  1. set a break point on the console.log line
  2. Using your Launch Edge configuration launch edge
  3. notice that Edge launches, and the page is displayed. Notice that the console log message appears in the console.

Expected behavior:

I expected my break point would be hit.

Additional context:

If you use npx reload -d public -p 3000 to serve the index page, the break point is also not hit.

Also, if you copy the html and launch.json file to a newly initialized node project npm init -y it also does work.

I was sure I’d seen this actually work before, so I deleted the node package.json file, but that did not help.

Finally, I have noticed that if you launch edge, then bring up the dev tools from the browser and set the break point using those tools (i.e. go into sources, find index.html, set a breakpoint) then the break point is hit and the file is opened in vs code. Oddly the file opened contains only the contents of the script tag, and the rest of the file is empty. image

image

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
chris-minercommented, Feb 22, 2022

Based on #896 I got the idea to try the headless option on my edge launch config. That didn’t help me at all, but it did lead to me changing my "webRoot": "${workspaceFolder}" entry to "webRoot": "${workspaceFolder}/public". And now my breakpoint is hit.

1reaction
codepo8commented, Feb 22, 2022

This looks to me more like an issue of JS debug, let’s find out more about that. Thanks for bringing it up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to debug html/client side js with node server running
I'm currently debugging in VSCode using ctrl + shift + p -> debug open link. which hits my breakpoints in js. But, when...
Read more >
Debug a JavaScript or TypeScript app - Visual Studio (Windows)
With your project open in Visual Studio, open a server-side JavaScript file (such as server.js), click in the gutter to set a breakpoint:....
Read more >
Debugging a Node js Express API in VS Code Debugger
Debugging Node js APIs with VS Code is very easy. We check which endpoint we want to debug and set a breakpoint inside...
Read more >
Breakpoints broken via Attach to running NodeJS process ...
Updated on two machines and on both machines breakpoints are no longer getting hit, despite Code appearing to be attached to the process....
Read more >
How to debug Node.js apps in Visual Studio Code
The Visual Studio Code debugger will try to auto-detect the debug environment for your project, but if this fails, you will be prompted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found