(window.webpackJsonp=window.webpackJsonp||[]).push([[332],{432:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return a})),n.d(t,"metadata",(function(){return c})),n.d(t,"rightToc",(function(){return p})),n.d(t,"default",(function(){return l}));var r=n(2),o=n(6),i=(n(0),n(456)),a={sidebar_label:"Debugging",title:"Debugging"},c={id:"guides/debugging",title:"Debugging",description:"Application Debugging",source:"@site/docs/guides/debugging.md",permalink:"/docs/guides/debugging",editUrl:"https://github.com/nodegui/nodegui/edit/master/website/docs/guides/debugging.md",sidebar_label:"Debugging",sidebar:"guides",previous:{title:"Architecture",permalink:"/docs/guides/nodegui-architecture"},next:{title:"Debugging in VSCode",permalink:"/docs/guides/debugging-in-vscode"}},p=[{value:"Application Debugging",id:"application-debugging",children:[]},{value:"Debugging Qode process",id:"debugging-qode-process",children:[{value:"Command Line Switches",id:"command-line-switches",children:[]},{value:"External Debuggers",id:"external-debuggers",children:[]}]}],u={rightToc:p};function l(e){var t=e.components,n=Object(o.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},u,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"application-debugging"},"Application Debugging"),Object(i.b)("p",null,"Whenever your NodeGui application is not behaving the way you wanted it to,\nan array of debugging tools might help you find coding errors, performance\nbottlenecks, or optimization opportunities."),Object(i.b)("p",null,"Since a NodeGui application runs on Qode. And Qode is essentially NodeJs. We can consider a NodeGui app as a regular NodeJs app. Hence, you can use any debugging tool that you use with NodeJs\nOne of the most popular ways of debugging a NodeJs app is by making use of the ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://nodejs.org/en/docs/inspector/"}),"Chromium Developer Tools"),"."),Object(i.b)("p",null,"Google offers ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://developer.chrome.com/devtools"}),"excellent documentation for their developer tools"),".\nWe recommend that you make yourself familiar with them - they are usually one\nof the most powerful utilities in any NodeGui Developer's tool belt."),Object(i.b)("h2",{id:"debugging-qode-process"},"Debugging Qode process"),Object(i.b)("p",null,"To debug JavaScript that's executed in the Qode/Node process you will need to use an external debugger and\nlaunch Qode with the ",Object(i.b)("inlineCode",{parentName:"p"},"--inspect")," or ",Object(i.b)("inlineCode",{parentName:"p"},"--inspect-brk")," switch. Once you run it you can open up Chrome and visit ",Object(i.b)("inlineCode",{parentName:"p"},"chrome://inspect")," where you should see your app listed."),Object(i.b)("h3",{id:"command-line-switches"},"Command Line Switches"),Object(i.b)("p",null,"Use one of the following command line switches to enable debugging of the process:"),Object(i.b)("h4",{id:"--inspectport"},Object(i.b)("inlineCode",{parentName:"h4"},"--inspect=[port]")),Object(i.b)("p",null,"Qode will listen for V8 inspector protocol messages on the specified ",Object(i.b)("inlineCode",{parentName:"p"},"port"),",\nan external debugger will need to connect on this port. The default ",Object(i.b)("inlineCode",{parentName:"p"},"port")," is\n",Object(i.b)("inlineCode",{parentName:"p"},"9229"),"."),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-shell"}),"qode --inspect=9229 your/app\n")),Object(i.b)("h4",{id:"--inspect-brkport"},Object(i.b)("inlineCode",{parentName:"h4"},"--inspect-brk=[port]")),Object(i.b)("p",null,"Like ",Object(i.b)("inlineCode",{parentName:"p"},"--inspect")," but pauses execution on the first line of JavaScript."),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"Note")),Object(i.b)("p",null,"If you are using the official boilerplate ",Object(i.b)("inlineCode",{parentName:"p"},"nodegui-starter"),", then you can achieve this by running"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{}),"npm run debug\n")),Object(i.b)("h3",{id:"external-debuggers"},"External Debuggers"),Object(i.b)("p",null,"You will need to use a debugger that supports the V8 inspector protocol."),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"Connect Chrome by visiting ",Object(i.b)("inlineCode",{parentName:"li"},"chrome://inspect")," and selecting to inspect the\nlaunched NodeGui app present there."),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",Object(r.a)({parentName:"li"},{href:"/docs/guides/debugging-in-vscode"}),"Debugging the NodeGui app in VSCode"))))}l.isMDXComponent=!0},456:function(e,t,n){"use strict";n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return g}));var r=n(0),o=n.n(r);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var u=o.a.createContext({}),l=function(e){var t=o.a.useContext(u),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},b=function(e){var t=l(e.components);return o.a.createElement(u.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,a=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),b=l(n),d=r,g=b["".concat(a,".").concat(d)]||b[d]||s[d]||i;return n?o.a.createElement(g,c(c({ref:t},u),{},{components:n})):o.a.createElement(g,c({ref:t},u))}));function g(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,a=new Array(i);a[0]=d;var c={};for(var p in t)hasOwnProperty.call(t,p)&&(c[p]=t[p]);c.originalType=e,c.mdxType="string"==typeof e?e:r,a[1]=c;for(var u=2;u