vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

[Feature Request] - Break on property change | subtree modifications

Open jasonwilliams opened this issue 5 years ago • 3 comments

There are scenarios where an object is updated but I'm unsure what updated it or when it happened. It would be nice to have something similar to Firefox's Break on subtree modification however I appreciate this feature is heavily DOM related and it would be nice to apply this to any object rather than just DOM nodes.

In the below example I'm testing a React component, and SubmitMock.mock changes, but I'm not sure what causes the update, it would be useful if I had an option here to break on subtree modifications (to the mock object). I don't know if Watch is the best place for it (as you can put arbitrary expressions in there), maybe the Variables view would make more sense.

image

Prior Art

Firefox Dev Tools

image

Chrome Dev Tools

https://developers.google.com/web/tools/chrome-devtools/javascript/breakpoints

Current workarounds

One way to get around this would be to add a setter on the object and call debugger inside. http://johnkpaul.com/blog/2013/07/20/break-on-property-change/

jasonwilliams avatar Jun 04 '20 11:06 jasonwilliams

Data breakpoints have been added for C and C#, would be nice to have this for javascript as well

kurdtpage avatar Jun 25 '20 01:06 kurdtpage

I like this idea and would find it quite handy myself. Implementing our own mechanism here (e.g. redefining properties or adding proxies) is not something I want to do since it is invasive and could cause confusing issues in the program. I want something on CDP, but it looks like there is nothing for that. https://bugs.chromium.org/p/chromium/issues/detail?id=1126093

connor4312 avatar Sep 08 '20 17:09 connor4312

Thanks for raising upstream!

jasonwilliams avatar Sep 08 '20 21:09 jasonwilliams