From ed210183e11a10993e5730f924cb11957a0aff73 Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sun, 24 Mar 2024 16:40:56 +0100 Subject: [PATCH] Revert "Don't expose Go timers directly to lua" This reverts commit 4ffc2206eeea4a7d58bdf283e35cdf28b29b0b42. Reason for revert: some plugins happen to use raw Go timers via time.AfterFunc(), in an unsafe way (without synchronizing their async code with micro). Let them keep doing that for now, in an unsafe way but at least without immediate crashes. Fixes #3209 --- internal/lua/lua.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/lua/lua.go b/internal/lua/lua.go index e17f2a66c..cea064ab3 100644 --- a/internal/lua/lua.go +++ b/internal/lua/lua.go @@ -521,16 +521,21 @@ func importErrors() *lua.LTable { func importTime() *lua.LTable { pkg := L.NewTable() + L.SetField(pkg, "After", luar.New(L, time.After)) L.SetField(pkg, "Sleep", luar.New(L, time.Sleep)) + L.SetField(pkg, "Tick", luar.New(L, time.Tick)) L.SetField(pkg, "Since", luar.New(L, time.Since)) L.SetField(pkg, "FixedZone", luar.New(L, time.FixedZone)) L.SetField(pkg, "LoadLocation", luar.New(L, time.LoadLocation)) + L.SetField(pkg, "NewTicker", luar.New(L, time.NewTicker)) L.SetField(pkg, "Date", luar.New(L, time.Date)) L.SetField(pkg, "Now", luar.New(L, time.Now)) L.SetField(pkg, "Parse", luar.New(L, time.Parse)) L.SetField(pkg, "ParseDuration", luar.New(L, time.ParseDuration)) L.SetField(pkg, "ParseInLocation", luar.New(L, time.ParseInLocation)) L.SetField(pkg, "Unix", luar.New(L, time.Unix)) + L.SetField(pkg, "AfterFunc", luar.New(L, time.AfterFunc)) + L.SetField(pkg, "NewTimer", luar.New(L, time.NewTimer)) L.SetField(pkg, "Nanosecond", luar.New(L, time.Nanosecond)) L.SetField(pkg, "Microsecond", luar.New(L, time.Microsecond)) L.SetField(pkg, "Millisecond", luar.New(L, time.Millisecond))