-
Hi all, I've tried and failed to find any prior art on setting up event callbacks in Luau (or even regular Lua) in a way that's compatible with the multiple thread setup needed (or recommended) for sandboxing. Note that I'm exclusively referring to Lua threads ( What we currently have is:
That last part appears to completely bypass at least some of the sandboxing... My gut feeling is that I need to store and execute event callbacks per-thread, which if I'm creating threads for each required file as the REPL does would be awkward to track (as I also need to know which packages these belong to) and lose most of the benefit of dispatching events partially in lua. My two questions are:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solved this myself (obvious once you think about it...) When the chunk is loaded, any functions to be passed to event registration functions have already had their global env bound, and that doesn't change when called from another thread (i.e. the main thread). Verified (I think) by printing the global env from inside one of those event listeners On the second question above, I've assumed yes as it was convenient to have a per-file global env anyway |
Beta Was this translation helpful? Give feedback.
Solved this myself (obvious once you think about it...)
When the chunk is loaded, any functions to be passed to event registration functions have already had their global env bound, and that doesn't change when called from another thread (i.e. the main thread). Verified (I think) by printing the global env from inside one of those event listeners
On the second question above, I've assumed yes as it was convenient to have a per-file global env anyway