How to handle script errors in Durandal SPA - durandal-2.0

When you get a script error somewhere in your SPA code, entire app becomes totally unresponsive and you cannot navigate to any other pages(views). It seems durandal just freezes! (only way out is to hit refresh to start SPA again)
What are some good ways to handle these unhandled exception scenarios in Durandal SPA?
Thoughts?
Thanks!

My experience is to use Chrome as main tool for debugging since I find the tools easiest to use. However, now and then Durandal reports that an error has occured. Not where or why it just stops and hangs as you describe. Then I try the same in Firefox with the Firebug plugin. Then the browser usually stops the code at the correct place.
I assume that you have activated debug mode in your main.js?

Related

Does IntelliJ or VSCode have the ability to set breakpoints that do not halt execution, instead taking a snapshot of stack/vars that you can view?

I'm currently on a team developing a Slack bot, we've begun the classic console.log debugging strategy and our log output is already getting extremely bloated. A team lead mentioned breakpoints and I decided it would probably be a good idea to start using them but there is a problem:
Slack bots are sometimes responding to requests in a time-sensitive manner. For instance, when opening a modal you only have 3 seconds following a user action to open the modal, clearly any breakpoint that halts execution before the modal is opened would cause problems.
Thinking about it, it seems like something that /should/ be possible. When reaching the breakpoint simply take the stack/vars that would be displayed and store/display them without halting execution. Unfortunately, 90% of the time I think "this should exist", it doesn't.
Well, I guess I could just google it huh?
IntelliJ - Tracepoint
VSCode - Logpoint

How to wait for the angular universal to fully charge?

My application works perfectly without angular universal . I display an image before the complete loading of my application(https://medium.com/#tomastrajan/how-to-style-angular-application-loading-with-angular-cli-like-a-boss-cdd4f5358554) but it does not work in anular Universal. It displays nothing. When rendering angular universal the breakpoint hits come too late and i want to avoid that
Angular Universal's entire point is that it will render on the server and not in the browser. So the article you linked in terms of having a loading image while Angular bootstraps won't happen with Universal as it's already "bootstrapped" on the server before it's given to you in the browser.
Another way to think about it is that you can use a loading gif OR use Angular Universal to achieve a similar result of not giving a user a blank screen.
In terms of the second part of your question with breakpoints not being hit. Again this is a quirk with Angular Universal in that because the first page request is rendered on the server, if you are attempting to debug something in the browser it's not going to work as you might first think because the rendering has already happened server side. To debug Angular Universal you need to debug both in browser, and using something like VS Code to debug as a regular NodeJS app. If that sounds like a headache it's because it is. Unless you have a really good reason to use Universal, I wouldn't recommend using it just because you can.
More info :
https://angular.io/guide/universal
https://tutorialsforangular.com/2020/04/04/3-things-they-dont-tell-you-about-angular-universal/

VS2012 debugging server side code with Google Chrome

I work on an asp.net mvc app.
This morning I was able to debug my server side code from a Google Chrome browser instance. I simply select Google Chrome in place of Internet Explorer in my VS2012 then click on it to run the app. When a breakpoint was reached (for example in my controller) it switch automatically to VS2012 for debugging.
This afternoon I am not able to do it again with Google Chrome. Only able to debug with Internet Explorer.
Any idea what's wrong?
It shouldn't matter which browser you tell VS to open your website in. If your debugger is attached to your C# your breakpoints should be hit as long as you're using the correct URI defined by your MVC app. I use fiddler and postman to debug my controllers all the time. Are you sure you didn't make any changes that would cause Chrome to make an incorrect request? Or perhapse the browser has cached old code and that's why the breakpoints are not being hit? I always open Chrome with ctrl + shift N to avoid having any caching issues.

How do I Start My Browser (Firefox) the Way Selenium Does?

I've got a Selenium test which crashes my browser (Firefox) whenever it runs. It's just a simple test (login, logout, login, logout, login ... crash) and I can't reproduce the crash when I do the same things manually, so I think the problem is with Selenium itself.
However, the issue could be that my Firefox starts with different options than when Selenium starts it. I could confirm that's not the case if I could start Firefox the exact same way Selenium starts it (eg. without plug-ins, with all history cleared, etc.) ... but I'm not sure how to do that.
Can anyone tell me which options to use to make Firefox run the same way as when Selenium runs it?
I was never able to find out how to emulate Selenium's use of Firefox. I tried using a fresh Firefox profile, but that still seemed to have differences from how Selenium ran Firefox.
Instead I wound up re-writing my test to be two tests, and then it was able to log in/out twice in the first test and once in the second test, avoiding the issue I was trying to debug (which only manifests when I try to log in/out 3 times in the same test).
If anyone can provide a better explanation of how to emulate Selenium's running of Firefox I'd be happy to accept that answer.

PrintWindow works in standalone application and does partially work in NPAPI plugin

I have a code, which captures a given window by PrintWindow function. Specifically I do capture web-pages in a browser. This code is tested in a standalone Windows application, and it works ok. The same code is incorporated into NPAPI plugin and loaded into Google Chrome. There problems happen. If Chrome has only one tab, the code works OK. If Chrome has 2 tabs, the code returns black box of expected size. I tested the standalone application and the plugin at the same moment, on the same window handle (Chrome_RenderWidgetHostHWND). Application does ALWAYS work, the plugin does ALWAYS fail if multiple tabs are open in the browser.
I'd really appreciate, if someone give a clue how to fix this.
Thanks in advance.
NB. Other methods of capturing windows are inapplicable due to even greater shortcomings for my usecase.
I bet you're running into sandboxing issues.
Your app is likely running at the "normal" integrity level, so it has no problem posting the WM_PRINT or WM_PRINTCLIENT message to the Chrome process. (PrintWindow uses these messages under the covers.)
When you're a plugin in Chrome, I believe your code runs as a "low" integrity process (which reduces the chances of things like shatter attacks). Thus it doesn't surprise me that sending the message to a window in another process fails.
Unfortunately, that doesn't explain why it works when Chrome has only one tab. Are you finding the same instance of Chrome_RenderWidgetHostHWND in both the app and the plugin in the case where you have multiple tabs open? In general, there's one of these windows per tab. How are you finding the window?

Resources