From c8d5da1cd2db1e5578d66ba434a88bf5ad2e082c Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Sat, 31 Jul 2021 15:04:02 -0300 Subject: [PATCH 1/3] feat: add debugging blackbox section --- debugging/README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/debugging/README.md b/debugging/README.md index fa847bb..09cf9cf 100644 --- a/debugging/README.md +++ b/debugging/README.md @@ -39,3 +39,65 @@ Name | Sponsor | Protocol available | State | [Chrome DevTools]: https://github.com/ChromeDevTools/devtools-frontend [Theseus]: https://github.com/adobe-research/theseus + +## Blackbox + +Blackbox is a popular term that allows debugging user-land code without touching in their internals. + +For futher reference in nodejs debugging follow [these instructions](https://nodejs.org/en/docs/guides/debugging-getting-started/). + +### Enabling Blackbox through UI + +// TODO: waiting https://github.com/GoogleChrome/developer.chrome.com/issues/1074 resolution and point to this tutorial. + +### Enabling Blackbox through CLI + +Let's create a file called `example-blackbox.js` to simulate a blackbox usage + +```js +module.exports = { + doSomethingAsync: async () => { + debugger + console.log('Async done') + } +} +``` + +Then we have our `index.js` file + +```js +const { doSomethingAsync } = require('./example-blackbox') +async function main() { + await doSomethingAsync() + console.log('Done!') +} + +main() +``` + +Start debugging using CLI: + +```console +node inspect index.js +``` + +and enable the blackbox by calling [`Debugger.setBlackBoxPatterns`](https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#method-setBlackboxPatterns) and passing the ignore regex, in our case a simple `example-blackbox.js`: + +```console +debug> Debugger.setBlackboxPatterns({ patterns: ['example-blackbox.js'] }) +``` + +Afterall, perform a `continue` and see the script be running without stopping into `example-blackbox.js` function. + +```console +debug> continue +< Async done +< +< Done! +< +< Waiting for the debugger to disconnect... +``` + +### Additional information + +The `blackbox` term was replaced by `ignore-list` at Google Chrome Dev Tools in latest versions. From dddf55a2957f5106f1abf53cecb1d18da4c28ca1 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Sat, 14 Aug 2021 19:11:26 -0300 Subject: [PATCH 2/3] docs(debugging): point to chrome documentation ignore-script through ui --- debugging/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/README.md b/debugging/README.md index 09cf9cf..b7db587 100644 --- a/debugging/README.md +++ b/debugging/README.md @@ -48,7 +48,7 @@ For futher reference in nodejs debugging follow [these instructions](https://nod ### Enabling Blackbox through UI -// TODO: waiting https://github.com/GoogleChrome/developer.chrome.com/issues/1074 resolution and point to this tutorial. +See the [ignore-script section](https://developer.chrome.com/docs/devtools/javascript/reference/#ignore-list) at Google Chrome reference ### Enabling Blackbox through CLI From 3c1d25d8e39f4ff2c26a9f6bb785363a43492ed1 Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Tue, 17 Aug 2021 16:13:15 -0300 Subject: [PATCH 3/3] update: change continue typo to `c` (cont) --- debugging/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/README.md b/debugging/README.md index b7db587..45b9f98 100644 --- a/debugging/README.md +++ b/debugging/README.md @@ -90,7 +90,7 @@ debug> Debugger.setBlackboxPatterns({ patterns: ['example-blackbox.js'] }) Afterall, perform a `continue` and see the script be running without stopping into `example-blackbox.js` function. ```console -debug> continue +debug> c < Async done < < Done!