luvit / lit

Toolkit for developing, sharing, and running luvit/lua programs and libraries.
http://lit.luvit.io/
Apache License 2.0
249 stars 58 forks source link

fix: invalid usage of uv.run() in command runner #332

Closed truemedian closed 3 days ago

truemedian commented 4 days ago

We have been calling uv.run() from inside of a libuv callback, which is not allowed. This moves the original call to uv.run() inside of the main xpcall, which is where it is necessary.

This allows the first call to uv.run() to be completely finished before we attempt to exit and call uv.run() again.

truemedian commented 4 days ago

Additionally: Luv has the information required to prevent this violation of the libuv API, perhaps it's worth adding an additional check there that ctx->mode == -1. Any other value indicates that the event loop is currently running.