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.

Add option --inspect dev-server

See original GitHub issue

When you run yarn rw dev we launch two processes:

  1. webpack dev server
  2. redwood dev server
yarn rw dev
yarn run v1.22.4
$ /Users/peterp/x/redwoodjs/example-invoice/node_modules/.bin/rw dev
$ /Users/peterp/x/redwoodjs/example-invoice/node_modules/.bin/dev-server
$ /Users/peterp/x/redwoodjs/example-invoice/node_modules/.bin/webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js

I would like to have the ability to pass --inspect in the dev-server: yarn rw dev api --inspect

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
aldonlinecommented, Aug 6, 2020

Glad to see we’re getting to debugging 😃

A few notes on debugging:

Sourcemaps

In order for any kind of debugging to work, one of the most important requirements is that sourcemaps for all the sources that end up participating at runtime (both client and server) are present and correct (and correctly linked/made available to the runtimes). Most compilers and bundlers such as webpack provide good sourcemap support out of the box, but tinkering with things like Babel macros can easily break them. A while back I tried to implement debugging and I ran into a few walls here, but I figured that it was lower priority (make it work, make it right, make it fast), so I didn’t bring it up. We can always fix sourcemaps manually if they are broken. I haven’t tried with the current version of Redwood so I don’t know how things stand. Just keep it in mind if you run into issues (ex: breakpoints not being correctly set).

Processes

There are two processes that Redwood users may want to debug:

  • The lambda dev server
  • The browser process

There is a third process: The webpack-dev-server process itself. Unless you’re a Redwood framework developer, it is unlikely you’ll want to debug it.

Lambda dev server (api side)

This process is owned by the CLI. Therefore, the CLI is responsible for starting the sub-process with --inspect. We need to implement this. Instead of reinventing the wheel, we could allow users to pass all of Node.js’s debug related command line options or, as @peterp suggests, have a generic mechanism for forwarding like -- (ex: yarn rw cmd -- a b c=d).

Browser process (web side)

This one is not our responsibility. Tools such as VSCode have the ability to launch Chrome in debug mode and leverage the DevTools protocol to enable debugging. If the sourcemaps are correct (which is our responsibility) then this is an IDE + Webpack affair. We just need to provide a cookbook with instructions. I will also provide a launch configuration automatically when using Decoupled Studio.

1reaction
dac09commented, Aug 5, 2020

What do you think of a separate command yarn rw dev:inspect or yarn rw debug instead? Might give you more room to change things!

Read more comments on GitHub >

github_iconTop Results From Across the Web

DevServer - webpack
This set of options is picked up by webpack-dev-server and can be used to ... Make sure that script references are added into...
Read more >
webpack-dev-server
There is also the option to add a reference to the webpack-dev-server ... The function can inspect the HTTP request, response, and any...
Read more >
How to detect if webpack-dev-server is running?
The webpack dev server will now set the WEBPACK_DEV_SERVER environment variable, allowing for a more robust way to check. const isDevServer = process.env....
Read more >
webpack-dev-server - npm
[options] Run the webpack dev server. Options: -c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js. -- ...
Read more >
DevServer - webpack 3 documentation
If you're using dev-server through the Node.js API, the options in devServer will be ignored. Pass the options as a second parameter instead:...
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