Compare commits
2 Commits
2023.10.21
...
2023.10.22
Author | SHA1 | Date | |
---|---|---|---|
22a3326be9 | |||
0cfb132b65 |
@ -19,29 +19,16 @@ func (m *LifecycleModule) Export(export *goja.Object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *LifecycleModule) OnInit(ctx context.Context, rt *goja.Runtime) (err error) {
|
func (m *LifecycleModule) OnInit(ctx context.Context, rt *goja.Runtime) (err error) {
|
||||||
call, ok := goja.AssertFunction(rt.Get("onInit"))
|
_, ok := goja.AssertFunction(rt.Get("onInit"))
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.Warn(ctx, "could not find onInit() function")
|
logger.Warn(ctx, "could not find onInit() function")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
if _, err := rt.RunString("setTimeout(onInit, 0)"); err != nil {
|
||||||
if recovered := recover(); recovered != nil {
|
return errors.WithStack(err)
|
||||||
revoveredErr, ok := recovered.(error)
|
}
|
||||||
if ok {
|
|
||||||
logger.Error(ctx, "recovered runtime error", logger.CapturedE(errors.WithStack(revoveredErr)))
|
|
||||||
|
|
||||||
err = errors.WithStack(app.ErrUnknownError)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
panic(recovered)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
call(nil)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user