[#7305] fixed deadlock when manually triggering the OnTerminate hook

Co-authored-by: Felix <FelixM@yer.tools>
This commit is contained in:
Gani Georgiev
2025-11-07 17:00:42 +02:00
parent 41607679a0
commit fcb5b5dd67
4 changed files with 30 additions and 6 deletions

View File

@@ -552,3 +552,19 @@ func TestBaseAppAuxDBDualBuilder(t *testing.T) {
}
}
}
func TestBaseAppTriggerOnTerminate(t *testing.T) {
t.Parallel()
app, _ := tests.NewTestApp()
defer app.Cleanup()
event := new(core.TerminateEvent)
event.App = app
// trigger OnTerminate multiple times to ensure that it doesn't deadlock
// https://github.com/pocketbase/pocketbase/pull/7305
app.OnTerminate().Trigger(event)
app.OnTerminate().Trigger(event)
app.OnTerminate().Trigger(event)
}