Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 5c9e1ab

Browse files
committed
webui: Fix a crash bug in the web interface event processing loop
This would sometimes happen when discussion messages were being sent. It might be a good idea to move the event processing code out of the webui daemon, so if it has any problems again it doesn't result in a web outage.
1 parent fd8135f commit 5c9e1ab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

common/postgresql.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3567,12 +3567,12 @@ func StatusUpdatesLoop() {
35673567
for _, u := range users {
35683568
// Retrieve the current status updates list for the user
35693569
var eml pgtype.Text
3570+
var userEvents map[string][]StatusUpdateEntry
3571+
var userName string
35703572
dbQuery = `
35713573
SELECT user_name, email, status_updates
35723574
FROM users
35733575
WHERE user_id = $1`
3574-
userEvents := make(map[string][]StatusUpdateEntry)
3575-
var userName string
35763576
err = tx.QueryRow(context.Background(), dbQuery, u).Scan(&userName, &eml, &userEvents)
35773577
if err != nil {
35783578
if !errors.Is(err, pgx.ErrNoRows) {
@@ -3582,6 +3582,9 @@ func StatusUpdatesLoop() {
35823582
}
35833583
continue
35843584
}
3585+
if len(userEvents) == 0 {
3586+
userEvents = make(map[string][]StatusUpdateEntry)
3587+
}
35853588

35863589
// If the user generated this event themselves, skip them
35873590
if userName == ev.details.UserName {

0 commit comments

Comments
 (0)