Cannot set breakpoints in Meteor Node app with VS Code - meteor

I must have a bad setting or some misunderstanding of how VS Code works. I cannot set breakpoints from my source code when I attach to a node process.
Environment:
OS: Windows 10
VS Code: 1.10.1
NODE: v4.7.3
Meteor: v1.4.5.1 (Node: v4.7.3)
Observed:
I set my environment variable set NODE_OPTIONS=--debug=5838. This will allow debuggers to connect to my program through port 5838. And this works perfectly for node_inspector.
I fired up my node server via npm in a command window (outside of VS Code).
I successfully attached to the node server.
Here are my attach settings for VS Code
{
"name": "Attach to Server",
"type": "node",
"request": "attach",
"port": 5838,
"address": "localhost",
"timeout": 20000,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/.meteor/local/build/programs/server/**/*.js"],
}
Note: my workspaceRoot is at E:\project\server
IFF I have a debugger; statement in my code when I connect VS Code will open the file that has the debugger; statement and I will be able to inspect my code and set breakpoints in this file. The file location for this file is \1003\file.js.
Note 1: I cannot set breakpoints in any other files unless I can bring it up through the debug session. For example, I can bring up other files by selecting callers on the call stack. But each file is from the origin e.g. \1004\otherfile.js not from my ${workspaceRoot}.
Note 2: Meteor creates one giant js file: app.js with all my code concatenated in it. There is a map file associated with it and I played around with setting my outFiles differently. It is set correctly, because it is able to discern which origin file is associated with the breakpoints. If I change the setting my breakpoint shows up in app.js.
Note 3: I also played around with remoteRoot assigning it to ${workspaceRoot} seems to mess up mapping such that it cannot find \1003\file.js anymore.
Expected:
I expected that VS Code would operate at least as well as node-inspector. node-inspector comes up with my source tree and remembers breakpoints between sessions. Very nice!
I expected that breakpoints I set in my source code would be loaded when I attached to my node server.
I expected that I would not need to put a debugger; statement in my code to be able to set breakpoints.
If I was unable to use my source code for setting breakpoints, I expected that I would see a directory of my origin source code so I could set breakpoints throughout it.
Conclusion
I must have messed up my configuration somehow. Maybe the debugger is unable to make the connection between my source code and the origin and I have to connect that properly?
I have been reading such good things about VS Code, especially the debugger that I figure I must be out to lunch somewhere...
Thanks for any insights!

Officially there is a recipe see VS Code Recipe
You need at least Meteor 1.6+ and Node.js 8.9+ for it to work.

Related

How can I set <UFTApp>.<TestOrComponent>.Settings.Run.OnError non-programmatically for interactive (i.e. IDE-based debug) runs of a BPT component?

In UFT 14.50 (but I don't think this is version-specific), I face the following problem:
For action-based GUI tests, I can configure for each test using File/Settings/Run what should happen in case of error:
For BPT GUI-based components, I cannot; there is no "Run" section:
Also in the application area for the component, which would be the second place where it would make sense to put this setting, there is no such setting.
I do understand that I can set this setting programmatically using <App>.<TestOrComponent>.Settings.Run.OnError.
I also understand that one can configure this setting in the execution setting for each component call in a BPT test flow script, or BPT test script, but what about interactive component execution for debugging reasons -- I have to change this setting in every component programmatically during runtime if I want to define/change this setting when doing debug runs in the UFT IDE, is this correct?
Bonus question: What is the rationale to hide this setting for a given component?
It's a good question. It's one i had to think about as there are quite a few components involved.
You build your code for BPT application areas in UFT but the BPT test itself is designed to be managed and executed from ALM. Around version 11 or 12 HP (the vendor at the time) updated the remote agent to have "debug mode" (the top option in these settings):
If you've not seen this you window, you get it from right clicking on the remote agent on your system tray:
(you can also set it by updating the mic.ini file - shout if you need more info on this)
I've not used BPT for about a decade, but that option in the remote agent I am very aware of. POTENTIALLY The run option you're after doesn't exist because, for BPT and it's aLM dependency, it's now all controlled through that debug run setting.
With it CHECKED, when you run a test from ALM you get the popup on error
With it UNCHECKED, when you run a test from ALM, if it hits an issue the error popup is suppressed.
You don't need to set your options programatically.
Bonus points answer: Logically this makes sense as you're potentially kicking off an entire test set from ALM and if you had 1 bad object/line in the first test and it blocked an entire overnight run you'd be fairly angry. At least this way you have your local machine as a deubg run but all remote execution machines have it unchecked so they just keep going. It becomes a machine configuration and not a script configuration.
If this doesn't work as you expect there are other ways of using a common function library with environment variables to set all to debug or all to carry-on mode.

Meteor android build version

I have a strange issue. I build my Meteor app and run it on android device using -
meteor run android-device --mobile-server=<my_aws_ip>:3000
When the app deploys immediately it connects to the server (and my javascripts etc works). After a few seconds, the page refreshs and none of the javascript callbacks work. Please help me debug this issue.
More information: If I change the client (and not the server), and deploy it, for the first few seconds, the changed client gets shown on the phone. After the first few seconds, the version which is present on the server is shown. So I think Cordova or Meteor is trying to fetch the client code from the server, which is breaking the app. Is there a way to prevent this behavior?
Even more data points -
My aws code does NOT have android and ios platforms installed. Because of this, I think the cordova plugins are not installed, causing a JS break somewhere.
Easiest fix I can think of is remove cordova autoupdate. This is being added by meteor-platform package. If I clone meteor-platform and comment out the cordova autoupdate, the app doesn't load.
Is there another way of removing autoupdate?
This sounds like you have a different version of your app deployed at the mobile-server address.
The local code is run in development mode. Your AWS one is likely in production mode (and may contain a syntax error).
When you run your app it sees the code is different and fetches the new/old (different) version with a hot code reload - hence the page refresh/flash.
To fix this, you need to find the syntax error in your code. It's best to view the ADB logger or run with meteor run --verbose android-device ....
This will provide a bit more information such as an Uncaught exception: cannot read .. of null error type error.
It's hard to say what the error is. The error prevents the rest of your code from executing. In production mode the entire project is one JS file. If there is an error of any kind half way along the file, the rest of the file will not execute.
Also, try loading <my_aws_ip>:3000 in your browser and watch for JS errors in the JS console.
You can also run it locally with --production to simulate a production build environment locally.
Enabling autoupdate but without a page refresh:
Reload._reload = function (options) {
console.log("Next load will load new version");
};

Meteor Environment - Blank and Everything Broken

I got to a point where Meteor seemed to just stop working, no HTML would load but the port was open, throwing basic console errors indicating that the most basic parts of the program weren't getting read.
After a lot of troubleshooting (clearing the database, restarting, logging out, using different ports), I just created a new Meteor project and copied and pasted my .html and .js files and the new project worked where the old project didn't.
So, question - how can I troubleshoot this in the future? Something was going on in the Meteor folder because the old and new files were exactly the same.
After a day, the error is happening all the time now and I can't create a single project. I tried uninstalling and reinstalling Meteor with no luck.
Also, the problem seems to be isolated to one port. I can open projects in other ports, but not in 3000.
Why is one port "breaking"? What can I do to fix this?
--Edit--
The HTML and CSS are loading, but in the default port 3000, the console reads
Uncaught ReferenceError: Package is not defined
It shows this code as the first error point:
/* Imports */
var Meteor = Package.meteor.Meteor;
Below is the Terminal:
--Edit--
So this is embarrassing, it seemed to be a cache problem. I cleared the cache, and I'm assuming it refreshed the .js files and now it works.
If anyone can answer why the errors were being thrown in the first place and how to fix besides creating an entirely new project, that would be hugely helpful!
please post your terminal so we have more clues to help you.
You definitely can run other ports, perhaps your port 3000 is used by another program.
Also, never run a meteor app as root.
Run meteor on a high port number. The default is 3000 when you don't give a --port argument. Connect to it via the URL printed in the console - e.g.
meteor --port 3001
http://localhost:3000/.
If you have settings.json then run meteor --settings settings.json

Dojo treegrid runs fine locally, but not on remote server

Using dojo's TreeGrid (v. 1.9.0) served by my local machine (mvc.net) the grid loads fine with my sample, hard-coded data. However, when served from a remote machine, I get the un-debuggable "Sorry, an error occurred".
Breakpoints within my formatters are not even hit, suggesting the problem does not lie with any unloaded dependencies within a formatter. This fails not only on initial startup, but also if at runtime I try to reload the model using .setModel(myNewModel) after everything has definitely loaded. I have the firebug flag set in the dojo config object, and no informative warnings or errors are showing up in firefox...just that annoying and useless message in the grid itself.
The Sorry, an error occurred message is a result of a problem with your store and usually the data you are putting into the store.
The message is shown in DataGrid._onFetchError and TreeGrid mixes in the DataGrid.
You can
put a break point on the query engine of what ever store you are using,
analyze the data being passed into the store

How to get a second browser running on a Selenium2 Grid Hub

I managed to get a Selenium Grid Hub running in my code (using a Groovy/Gradle build system), and I loaded configuration from a .json config file and when I run my tests it only runs a single thread. I configured my Grid server to have a max of 2 sessions. How do I get my unit test (or the grid) to actually start a second browser? I looked everywhere on the Selenium site and on Google and everyone fails to mention how to do it, as if it is something that everyone already knows. Am I missing something here?
Here is where I have my config files for my Hub and Node :
https://github.com/djangofan/WebDriverTestingTemplate/tree/master/root
You are looking for DesiredCapabilities.
In java you would write something like this:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
RemoteWebDriver driver = new RemoteWebDriver(yourGridUrl, capabilities);
This would start the chrome browser on your grid.

Resources