Recently, in a piece of software I'm working on, I have been receiving a spate of errors in Sentry from clients that I'm having a lot of trouble pinning down. The specific error is this:
Non-Error promise rejection captured with value: 'registerDomMutation' is not defined
The specific error seems to be generated by Sentry itself as it attempts to capture some other problem. What has really got me stuck is that I can't track down where registerDomMutation is being called, or which piece of software that should be defining it. It doesn't appear to be part of Sentry; I know that it's not in my code; and it doesn't appear to be in any of the packages I use. It sounds like it could be a browser method of some kind, but I can't find any information on it. This error only seems to be occurring in the new version of iOS Safari (14.3), but it's also not occurring consistently.
Is anyone familiar with this method? Can you point me in the right direction?
I believe they're coming from internal WebView of Klarna application. I cannot seem to find any source code for the app to prove this point. But recurring Klarna/<some version> pattern shared among all the errors' userAgent string makes me think so.
Android version of the app is affected too. I guess they are sharing the same JS code.
I have strict CSP rules regarding scripts allowed to run on my page and I guess some code the app is relying on just doesn't run due to them.
I've googled for 'V8 mksnapshot' and found out that there is a 'snapshot' feature in V8 engine, also there is this question here
This feature seems to be an outstanding feature for bug reproduction in case of Node.js server fault.
The scenario
You use 'process.dumpAll' in some error-handler of Node.js server, maybe attach it process-wise, maybe filter error events somehow.
If a problem occur - all the V8 state is saved into a dump-file
Later when you want to reproduce the problem you can re-run Node.js from this dump
You than attach a debugger to Node.js, the process would be on in suspended state - same thing if 'debugger' is triggered, current statement would be 'process.dumpAll' function.
Now you can inspect every objects' state in V8.
I'd like to ask
Where can I find better documented (better than some chatting on forum) more info about V8 snapshots?
Do you see any pitfalls for this scenario?
What are the first steps should I take to implement a function 'process.dumpAll' and 'process.loadAll' for Node.js? (excluding knowledge about writing Node.js extensions)
Maybe someone is already making or made some solution for this?
V8's mksnapshot feature is not designed for postmortem debugging (but for startup acceleration), and I doubt that it could be useful for that purpose.
Coredumps (for crashing processes) and DevTools / heap snapshots (for exceptions) are in all likelihood more useful for debugging purposes.
There are some existing efforts for Node.js postmortem debugging. Maybe just knowing the right search engine query can help you get an overview of existing solutions, their abilities and limitations?
I'm using Node for running my unit-tests.
I have a JavaScript module run in the browser I'd like to test.
My code is "isomorphic", i.e. it avoids language features not available in Node, like exports.
But it uses pure browsers APIs: XMLHttpRequest, FormData and File.
I have found Node's implementations for each of them.
But the one of XMLHttpRequest does not support upload.
So I'm looking for the simplest way to unit-test this code in an environment with these APIs.
The code does not need DOM or other browsers APIs, "only" these three.
I've already used PhantomJS for other needs but:
this will create another test workflow (minor issue),
it supports an older JavaScript version and it would force a complete rewrite of the code to test (major issue),
the code has a lot of NPM dependencies that probably won't be compatible (blocking issue).
As the code is Browserified all these issues may disappear but before going along this way I'd like to be sure.
Is there any chance to get it work with PhantomJS, CasperJS or the like?
Which other alternatives are available?
This is not how you test code that runs in a browser. If it runs in a browser, it needs to be tested in a browser.
You need to look into solutions based on the webdriver spec. The big hairy monster in this ecosystem is Selenium. I'm currently researching this topic because of some issues we've had with using selenium-server. You should also look into Nightwatch and Leadfoot. Webdriver.io is the first recommendation a lot of people recommend, as its a node-based client that wraps (poorly) around Selenium. But the documentation is all over the place and we've run into frequent bugs using it.
Sorry, maybe this belongs in programmers stack exchange, but I'm trying to get in to Node.js web development, and I really need to ability to step through my code in order to gain a deeper understanding of just what is happening in all the tutorials I'm using.
I've done some googling, but it looks like everything is written assuming you're in a *nix or OSX environment.
I've tried node-inspector, but I'm being greeted with errors whenever I try to run process._debugProcess() with the PID.
JetBrains WebStorm is relatively inexpensive IDE you can use with Node.js, which is quite feature rich considering the price.
Watch the demonstration video and you should get an idea to see if it's the kind of thing which could be helpful.
http://www.jetbrains.com/webstorm/
Alternatively you could use Eclipse and get this up and running.
https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger
I'm pretty new to workign with Javascript.
In most languages you can run the code quickly locally on your machine. From what I've seen, in JS you generally only use it via the browser, and so I've been uploading my code an viewing its effects in the browser. This has proven very tiresome. Also, if I mak one error, it seems like my JS/JQuery will just do NOTHING, instead of giving me a useful error, message, which is making it painfully slow to code in.
IS there some way to run JS locally to see that it is working as I go? And then only upload it to the web when I'm mostly done? What ways are there for me to do this? What ways aer there for me to unit test the Javascript locally? Say I have some JAML that should render as <p>HI</p>, how do I run this locally in a unit test?
Thanks for the help,
Alex
EDIT:
Thanks for all the great suggestions. I'll have to take a bit of time and go through them to see which ones best help me in my situation.
Since you're using jQuery, I assume that you actually want to manipulate the various elements on your page. So depending on your specific development enviroment, uploading it each time is probably the way to go anyway. If you can set up a dev enviroment on your local machine (not always possible) then go with that.
As an actual answer to your question, I suggest using Chrome's developer tools, it doesn't just have the console, but an element inspector, and a resource tracker (resource tracker is invaluable when working with JSON and AJAX, since invalid json will fail silently)
As far as I know, the firebug plugin for firefox (dont use it myself) has a similar feature set, so if you're more comfortable with that go with it.
Just remember, as a developer, your development (and debuggin) enviroment is just as important as the code that you are writing.
EDIT: Noticed that you mentioned unit testing. There are several unit testing frameworks out there for JS including one that integrates with firebug called FireUnit. Do a quick google search to find more if you want.
You don't need to upload the JS file to a server to test it. Just write an html and declare the js binding
<script
src="js/yourJSFile.js"
type="text/javascript"></script>
Edit the JS file in your favorite editor and then refresh the page to test it.
For unit testing the best option is Selenium. It allows you to record an interaction with the browser and then play it back.
You can use Firebug with Firefox to debug JS, and Google Chrome has a debugger built-in (use the Tools -> Developer Tools menu).
You can run Javascript from the local file on your machine in your browser, so you can skip the uploading step.
Also, I'd recommend using Firefox/Firebug combo for developing Javascript as it will be very handy, especially for the part you mentioned about not seeing what's going wrong with your code.
Even if you upload your javascript it gets downloaded back to you as soon as you visit the webpage that invoques it. Its run client side always. So stick to local and use firebug as the others have said. Google`s developer tool is quite nice too.
In the browser if you open the developer tools, follow the following steps:
1) Navigate to sources
2) Under sources, click snippet and open run.js
3) You can use run.js to write as much code as you want and run it locally only to see if your code is working or not (it will give you output on the console)
4) Also you can get used to some keyboard shortcuts to make it faster for you.
5) For small javascript codes, you can navigate to console and run your code there
If you want to do unit testing with Javascript there are extension of Firebug that can help you with that. I haven't try any of them, so I can't really tell you which one are worth considering, but you can easily find them if you search for the keyword "Firebug unit testing" on Google.
What seems to be comming on top is FireUnit. You can find some information about how it works here.
Consider Spider Monkey, which is a javascript engine separate from a browser. If what you are developing does not involve rendering to a webpage or can be separated from the rendering code (good practice!), then this could be useful.
I prefer Chrome to Firefox and I just found Web Server for Chrome.
It's just a Google App that quickly sets up a web server for you and will be set up anywhere you are logged into Chrome. It only allows file access to your current devices, or if you specify, other devices only on the current LAN.
You just point it to the directory with your index.html file and type http://127.0.0.1:8887 in your browser.
Additionally to the answers given you can use Jasmine for automated testing.
A tutorial that seems to help get started with automated testing on Jasmine is provided by Evan Hahn.
I used it and for me it works like a charm. Especially if test driven development is what you are going for!