mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 17:44:59 +09:00
recover panics for addon/mobile mode
This commit is contained in:
parent
81ec616145
commit
f06bc92c8f
4 changed files with 1598 additions and 369 deletions
|
@ -22,6 +22,7 @@ var mw = core.New()
|
|||
func init() {
|
||||
fmt.Printf("mw jsaddon: %s\n", core.GetVersionDescription())
|
||||
registerClientCommandsHandler(mw)
|
||||
PanicHandler = mw.OnPanic
|
||||
metrics.SharedClient.InitWithKey(metrics.DefaultAmplitudeKey)
|
||||
if debug, ok := os.LookupEnv("ANYPROF"); ok && debug != "" {
|
||||
go func() {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,7 @@ package core
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
|
||||
"github.com/anytypeio/go-anytype-middleware/app"
|
||||
|
@ -36,7 +37,8 @@ type Middleware struct {
|
|||
}
|
||||
|
||||
func New() *Middleware {
|
||||
return &Middleware{accountSearchCancel: func() {}}
|
||||
mw := &Middleware{accountSearchCancel: func() {}}
|
||||
return mw
|
||||
}
|
||||
|
||||
func (mw *Middleware) Shutdown(request *pb.RpcShutdownRequest) *pb.RpcShutdownResponse {
|
||||
|
@ -96,6 +98,11 @@ func (mw *Middleware) GetApp() *app.App {
|
|||
return mw.app
|
||||
}
|
||||
|
||||
func (mw *Middleware) OnPanic(v interface{}) {
|
||||
stack := debug.Stack()
|
||||
log.With("stack", stack).Errorf("panic recovered: %v", v)
|
||||
}
|
||||
|
||||
func init() {
|
||||
logging.SetVersion(GitSummary)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ type debug struct {
|
|||
|
||||
func (d *debug) Init(a *app.App) (err error) {
|
||||
d.core = a.MustComponent(core.CName).(core.Service)
|
||||
d.store = a.MustComponent(objectstore.CName).(objectstore.ObjectStore)
|
||||
d.store = a.MustComponent(objectstore.CName).(objectstore.ObjectStore)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,5 @@ func (d *debug) DumpTree(blockId, path string) (filename string, err error) {
|
|||
return
|
||||
}
|
||||
builder := &treeBuilder{b: block, s: d.store}
|
||||
|
||||
return builder.Build(path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue