0

I'm maintaining an enterprise C# application that provides end-user extensibility through user-defined JavaScript functions (with a select few C# types/proxies exposed) (think financial algorithms).

We evaluate those functions using ClearScript (prevously we were using another library called Noesis however we've moved away from that).

I'd like to offer a way for end-users to perform very basic debugging of the scripts (through a web interface). At a minimum - inspect variables and step over/into functions.

I've successfully connected to the ClearScript engine w/ Chrome when running the app locally and have been able to step through the scripts - however I don't think the same would make sense for end users whilst running in production for various reasons:

  • Might be too tricky for them to set up
  • Possible difficulties with port allocation
  • Probable firewall issues

What I'd really like is a SignalR interface to the V8 debugger - the web-app would interact with the SignalR, and SignalR would interact with the V8 debugger.

  • Has anyone done something along these lines before?
  • Are there any relevant .NET libraries I should be looking at?
  • Am I right in my thoughts that this seems like a fairly big piece of work?
  • Any other advice?
4

2 回答 2

0

它是一个基于 web-socket 的协议——尽管您必须通过 HTTP 发出请求以首先检索 tabId(请求到/json/list

https://chromedevtools.github.io/devtools-protocol/1-2/Debugger描述了该协议 - 针对不同版本的 Chrome 有不同的修订版,但 1.2(稳定版)似乎与我使用的 ClearScript 版本一起工作。

除了 websocket 上的请求-响应(命令)类型的交互,V8 还将发布事件 - 例如Debugger.scriptParsed&Debugger.paused在同一个套接字上。

一些关键命令: Runtime.enable Debugger.enable Runtime.runIfWaitingForDebugger Debugger.getScriptSource Debugger.resume Debugger.evaluateOnCallFrame Runtime.getProperties

我编写了一个小型演示项目https://github.com/flakey-bit/ClearScriptDebugging/,它显示了一个目标进程正在被另一个进程调试。

于 2019-05-25T08:16:55.613 回答
0

如果您提到 Chrome 和 Nodejs,您可能知道 Nodejs、Chrome 和 Edge 自然支持 WebSocket。Chrome 和 Edge 更适合所有安全选项。对于 Nodejs,您可以找到像 socket.io 这样的标准库。对于服务器端DotNet WebSocket WebSocket 协议是当今的 linga franka。

于 2019-05-27T10:06:28.977 回答