diff --git a/src/editor/engine/lua/LuaSharedSandbox.js b/src/editor/engine/lua/LuaSharedSandbox.js index ce0b15e..6446408 100644 --- a/src/editor/engine/lua/LuaSharedSandbox.js +++ b/src/editor/engine/lua/LuaSharedSandbox.js @@ -183,7 +183,15 @@ export class LuaSharedSandbox { Source = nil, } local co = coroutine.create(function() - ${entry.code} + -- pcall защищает от runtime-ошибок которые иначе крашат + -- coroutine и могут повредить WASM-стейт. Возвраты + -- handler'а намеренно поглощаются. + local ok_, err_ = pcall(function() + ${entry.code} + end) + if not ok_ then + __rbxl_send_error(${JSON.stringify(entry.id)}, tostring(err_)) + end end) __rbxl_register_coroutine(${JSON.stringify(entry.id)}, co) local ok, ret = coroutine.resume(co)