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

Debugging Server Rendering with the Node VM Rendering Server #1196

Open
justin808 opened this issue Feb 20, 2019 · 0 comments
Open

Debugging Server Rendering with the Node VM Rendering Server #1196

justin808 opened this issue Feb 20, 2019 · 0 comments

Comments

@justin808
Copy link
Member

justin808 commented Feb 20, 2019

Motivation

Because server rendering often uses react_component_hash to get the meta tags for SEO, we can't just flip a switch and turn off server rendering to debug the code in the browser. Here are the steps to debug the rendering code if using the React on Rails Pro Node VM Renderer

  1. Start the compilation of the webpack files and in a separate process.
  2. Start Node process in its own shell with this command, like this:
node --inspect vm-renderer.js -p 3800
  1. Open up the Chrome dev tools devices: chrome://inspect/#devices
  2. Click the "Configure..." button next to Discover network targets.
  3. Look at your terminal for for the vm-renderer and add the port corresponding to a line looking like Debugger listening on ws://127.0.0.1:9229/84cd33a7-8965-48f6-ad6b-31d9e368b667.
  4. Open up the debugger window by clicking inspect under the Target that does not have the version of Node listed.
  5. When you click inspect, you'll see the message Debugger attached. in the your terminal window for the vm-renderer.
  6. Add a debugger line to the place in the rendering JavaScript code where you'd like the debugger to stop.
  7. Hit the affected URL in the browser and the debugger window should open to the line where you put the debugger breakpoint.
  8. You can navigate in the stack up to App and see what props are coming from Rails.

Troubleshooting

On the chrome://inspect/#devices

  1. Double check that you configured the right network target. Check your console log from the vm-renderer
  2. Try clicking the other "Target" under "Remote Target.
  3. Since the workers restart per the console message: [ROR-VM] info: Scheduled workers restarts every 15 minutes (2 minutes btw each) you will need to reattach the debugger.

Setup

2019-02-17_19-01-52

2019-02-17_19-02-11

2019-02-17_19-17-21

2019-02-17_21-52-29

2019-02-17_19-10-43

Debugger line

2019-02-17_21-37-19

Seeing props sent to the app

2019-02-17_22-09-12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant