-
Notifications
You must be signed in to change notification settings - Fork 518
Debug with Angular Universal/prerenderer module #202
Comments
Well, basically any output from server should go directly to your console, so any console.log should work. In universal app i think it only possyble way to do this. You may also try to debug you node code, but it much more harder. |
The only clue I get is the following mesage: How could I debug that? |
What is your setup for prerendering? Default options? Can you try to change protocol to |
I ran the yeoman aspnetcore-spa generator with Angular2 and I haven't touched the How can I change the protocol to default sockets? I looked around and googled it, but can't find anything. |
@tinchou I ran into the same issue myself when playing with nested routing. Turning off the SpaServices Prerendering tag helper did the trick. Also, alternatively removing all bindings on the nested template prevented it from timing out. My guess is it has something to do with the async timing of nested levels of component bindings. I wonder if pre-rendering is compatible in that scenario. On a side note, it would be nice if I had a nice way of setting a break point in the code during node rendering since it is all compiled on the server during a refresh. |
I've updated some parts of these libraries so that they support attaching a I'll add full docs for this later, but first, let's see if you can make it work based on these notes :) Prerequisites
Enabling debugging In your
You probably also need to add Make sure you're running everything in debug mode. For example, in your command line, set the Now, run your application from that command line (e.g., In the console, you should see all the normal trace messages appear, plus among them will be:
In some other command line window, follow those instructions (i.e., install By expanding the (Note: although this looks like Chrome's native debugger for client-side code, it is actually a JavaScript-powered debugger UI that's connected to the server-side runtime) Summary As you can see, getting this to work is all quite delicate and fiddly. Maybe one day it might be possible to use VS Code as the debugging UI, but I'm not sure how far away that might be. If you hit any trouble getting this to work, please let me know! |
@SteveSandersonMS This looks amazing! Great Job! I tried it out for myself and I am running into problems with node.exe failing to initialize. Do you have any idea what might be happening? fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0] |
Ah yes, I think I see what's wrong. It looks like Node behaves slightly differently in an IPv6 environment, which appears to be the case for you given the error message you got. I've made a fix and published it as Microsoft.AspNetCore.NodeServices version 1.0.0-beta-000009. Could you try updating to that and see if it starts working? |
@SteveSandersonMS It works! And here I thought I didn't provide enough diagnostic information. I can confirm that I am in fact configured to use IPv6 with IPv4 as fallback. You should know that this solution only works when I open my chrome browser to the above address. When attempting to open in Edge, I receive the following error in my browser's console: "Unknown experiment canvasInspection" I assume this has something to do with EdgeHTML 13 not on feature parity with Chrome 52 (current versions as of now). What is this "canvasInspection" anyways? I guess a feature request is now in order to make node-inspector compatible with other browsers or to add this canvasInspection API to Edge. Any suggestions on the best route to enable node-inspector on the Edge browser? |
Contact the node-inspector project folks. But bear in mind that the debugger UI here probably comes from the Chrome project (since it's the same UI that ships in Chrome as the native JS debugger), and they might consider that to be the only important use case. I'd suggest you just use Chrome for debugging with node-inspector! |
@SteveSandersonMS I thought that is what you would say. Bummer! I found another two things that are causing me issues with node-inspector.
|
It works great! It really helped me identify some issues in the backend. Looks good to close, but don't forget to document this somewhere! |
Works, but I get a lot of |
Are you really sure? Try |
Yeah I tried closing all node processes and starting over (I'm actually on windows btw):
It works fine but after a few HMR/webpack rebuilding cycles, the error eventually manifests (and multiple node instances as well, 3 when originally there were 1). |
I am using windows and the same issue happens after code change and node restart when debugging enabled.
|
Just a quick note ... |
Hi!
I just started a new demo project using the Yeoman template with Angular2.
I have been having some trouble debugging when the prerenderer module is enabled. The main issue here is that we don't get any feedback from the server when there's an issue during prerendering i.e. in the console after running
dotnet run
.I've had some moderate success when I made mistakes in my client side code by disabling this in the
Home/Index.cshtml
file:But now I'm experiencing a new issue with the same behavior as I had with client side errors (page taking a long time to load followed by an error page), but if I disable prerendering it works fine.
I'm not asking to be helped in solving my particular issue: I'm sure it's a simple mistake I made because I'm new to Angular2. But I do want to know what to do to debug this, and suggest adding more information to the console output about the prerendering process. Maybe just outputting the javascript logs (e.g.
console.log
,console.error
calls) would be enough.Thanks!
The text was updated successfully, but these errors were encountered: