WICG / observable

Observable API proposal
https://wicg.github.io/observable/
Other
575 stars 14 forks source link

Debugging Observables #55

Open littledan opened 1 year ago

littledan commented 1 year ago

When we’ve tried to use Observables libraries in Bloomberg, we’ve had some trouble reasoning about this code and debugging it. Not being able to step through the code, knowing which of multiple streams are stopped/started, or thinking about streams inside of streams, blows the majority of people's mental capacity budget, especially when maintaining code written by someone else.

Strong DevTools support could really help with a lot of these issues. I know it’s not something that goes in the actual specification, but having a plan here would be really helpful in understanding the realities of using this feature. Chrome has blocked shipping other features on adequate DevTools support (e.g., async/await). Do you have any particular plans related to Observables?

benlesh commented 1 year ago

Definite plans? Not from me, because I'm not really in a position. But I'd have asks.

Chrome did ship console.createTask recently, which is interesting and perhaps useful for debugging things like Observables written in the wild. It basically adds labels to stack traces. The major reason RxJS didn't adopt it is it added a lot of complexity to the code, and it also created even more closures. (Async Context may also be useful for RxJS for debugging reasons).

That said, if this was native and built into the browser, I would expect call stacks you'd see coming from user-land implementations like RxJS to be reduced by 4x-5x, because they would just be [native call] under the hood everywhere. It should be glorious.

If I had dev tools asks, it might be some sort of stream dependency visualizer that allowed folks to see where observables came from, what steps there were in the chain of observation, and gave them the ability to jump to certain lines of code or set break points.