lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I managed to debug a lua script running on lua.vm.js through mobdebug by faking luasocket well-enough.A node.js serves as a proxy between synchronous xmlhttprequests and tcp traffic that the mobdebug server can understand.See
Does anyone knows a better way of doing it?
This below is a paste of my research notes (also on github):

(To my best knowledge)
The main problem is establishing communication between the mobdebug client and server.These are built to use tcp connections, which in general aren't available in client-side _javascript_. The other means of communication are websockets and xmlhttprequests.
However, websockets are asynchronous: one makes a receive request and then must wait for a callback to be fired, and for that to happen we have to let _javascript_ process events.
That means stopping the vm, so that the _javascript_ function that called the vm can return. I do not know how the vm works, so manipulating it from _javascript_ was out. Maybe coroutines would work.
However there's no way to yield from lua debug hooks and consequently asynchronous communication is ruled out.
Therefore xmlhttprequests, which can be forced to be synchronous, and therefore do not need to yielded, were left.
However firefox marks them as deprecated in the main thread; for now it will work.