fix(systemviews): avoid action worker race
- commit
- e074a737b0212b79b6d9526da5e0b093f11ff379
- author
- brice · · 2026-04-24 08:38 UTC
- parent
- 92bee5e
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +5 -4
M assets/systemviews/systemviews.wasm.br +0 -0 binary file: no text diff
binary file: no text diff
M internal/ui/systemviews/app.go +5 -4
| @@ -89,10 +89,11 @@ func (a *App) bindDOMActions(ctx context.Context, binder DOMActionBinder) error | |||
| 89 | 89 | a.actionMu.Lock() | |
| 90 | 90 | if a.actionQueue == nil { | |
| 91 | 91 | workerCtx, cancel := context.WithCancel(ctx) | |
| 92 | - | a.actionQueue = make(chan DOMAction, 64) | |
| 92 | + | queue := make(chan DOMAction, 64) | |
| 93 | + | a.actionQueue = queue | |
| 93 | 94 | a.actionCtx = workerCtx | |
| 94 | 95 | a.actionCancel = cancel | |
| 95 | - | go a.runActionWorker(workerCtx) | |
| 96 | + | go a.runActionWorker(workerCtx, queue) | |
| 96 | 97 | } | |
| 97 | 98 | a.actionMu.Unlock() | |
| 98 | 99 | return binder.BindActions(func(action DOMAction) { | |
| @@ -134,12 +135,12 @@ func (a *App) enqueueDOMAction(action DOMAction) bool { | |||
| 134 | 135 | } | |
| 135 | 136 | } | |
| 136 | 137 | ||
| 137 | - | func (a *App) runActionWorker(ctx context.Context) { | |
| 138 | + | func (a *App) runActionWorker(ctx context.Context, queue <-chan DOMAction) { | |
| 138 | 139 | for { | |
| 139 | 140 | select { | |
| 140 | 141 | case <-ctx.Done(): | |
| 141 | 142 | return | |
| 142 | - | case action, ok := <-a.actionQueue: | |
| 143 | + | case action, ok := <-queue: | |
| 143 | 144 | if !ok { | |
| 144 | 145 | return | |
| 145 | 146 | } | |
| @@ -89,10 +89,11 @@ func (a *App) bindDOMActions(ctx context.Context, binder DOMActionBinder) error | |||||
| 89 | a.actionMu.Lock() | 89 | a.actionMu.Lock() | ||
| 90 | if a.actionQueue == nil { | 90 | if a.actionQueue == nil { | ||
| 91 | workerCtx, cancel := context.WithCancel(ctx) | 91 | workerCtx, cancel := context.WithCancel(ctx) | ||
| 92 | - | a.actionQueue = make(chan DOMAction, 64) | 92 | + | queue := make(chan DOMAction, 64) |
| 93 | + | a.actionQueue = queue | |||
| 93 | a.actionCtx = workerCtx | 94 | a.actionCtx = workerCtx | ||
| 94 | a.actionCancel = cancel | 95 | a.actionCancel = cancel | ||
| 95 | - | go a.runActionWorker(workerCtx) | 96 | + | go a.runActionWorker(workerCtx, queue) |
| 96 | } | 97 | } | ||
| 97 | a.actionMu.Unlock() | 98 | a.actionMu.Unlock() | ||
| 98 | return binder.BindActions(func(action DOMAction) { | 99 | return binder.BindActions(func(action DOMAction) { | ||
| @@ -134,12 +135,12 @@ func (a *App) enqueueDOMAction(action DOMAction) bool { | |||||
| 134 | } | 135 | } | ||
| 135 | } | 136 | } | ||
| 136 | 137 | ||||
| 137 | - | func (a *App) runActionWorker(ctx context.Context) { | 138 | + | func (a *App) runActionWorker(ctx context.Context, queue <-chan DOMAction) { |
| 138 | for { | 139 | for { | ||
| 139 | select { | 140 | select { | ||
| 140 | case <-ctx.Done(): | 141 | case <-ctx.Done(): | ||
| 141 | return | 142 | return | ||
| 142 | - | case action, ok := <-a.actionQueue: | 143 | + | case action, ok := <-queue: |
| 143 | if !ok { | 144 | if !ok { | ||
| 144 | return | 145 | return | ||
| 145 | } | 146 | } | ||