You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-25 15:42:01 +02:00
remind users to call e.Next() in the OnBootstrap hook if the app is still not initilized after the hook trigger
This commit is contained in:
10
core/base.go
10
core/base.go
@@ -381,7 +381,7 @@ func (app *BaseApp) Bootstrap() error {
|
|||||||
event := &BootstrapEvent{}
|
event := &BootstrapEvent{}
|
||||||
event.App = app
|
event.App = app
|
||||||
|
|
||||||
return app.OnBootstrap().Trigger(event, func(e *BootstrapEvent) error {
|
err := app.OnBootstrap().Trigger(event, func(e *BootstrapEvent) error {
|
||||||
// clear resources of previous core state (if any)
|
// clear resources of previous core state (if any)
|
||||||
if err := app.ResetBootstrapState(); err != nil {
|
if err := app.ResetBootstrapState(); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -421,6 +421,14 @@ func (app *BaseApp) Bootstrap() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// add a more user friendly message in case users forgot to call
|
||||||
|
// e.Next() as part of their bootstrap hook
|
||||||
|
if err == nil && !app.IsBootstrapped() {
|
||||||
|
app.Logger().Warn("OnBootstrap hook didn't fail but the app is still not bootstrapped - maybe missing e.Next()?")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
type closer interface {
|
type closer interface {
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ func main() {
|
|||||||
},
|
},
|
||||||
Priority: 999, // execute as latest as possible to allow users to provide their own route
|
Priority: 999, // execute as latest as possible to allow users to provide their own route
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := app.Start(); err != nil {
|
if err := app.Start(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user