5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 01:41:30 +08:00

recover from process message instead crash the whole app (#4016)

* recover from process message instead crash the whole app

* update changelog.mdx (#4015)
This commit is contained in:
ronaldinho_x86 2025-01-17 13:45:54 +08:00 committed by GitHub
parent c4fdfd6415
commit 4598af4d7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package dispatcher
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/wailsapp/wails/v2/internal/binding"
"github.com/wailsapp/wails/v2/internal/frontend"
@ -29,7 +30,20 @@ func NewDispatcher(ctx context.Context, log *logger.Logger, bindings *binding.Bi
}
}
func (d *Dispatcher) ProcessMessage(message string, sender frontend.Frontend) (string, error) {
func (d *Dispatcher) ProcessMessage(message string, sender frontend.Frontend) (_ string, err error) {
defer func() {
if e := recover(); e != nil {
if errPanic, ok := e.(error); ok {
err = errPanic
} else {
err = fmt.Errorf("%v", e)
}
}
if err != nil {
d.log.Error("process message error: %s -> %s", message, err)
}
}()
if message == "" {
return "", errors.New("No message to process")
}

View File

@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [windows] Fixed frameless window flickering when minimizing/restoring by preventing unnecessary redraws [#3951](https://github.com/wailsapp/wails/issues/3951)
- Fixed failed models.ts build due to non-json-encodable Go types [PR](https://github.com/wailsapp/wails/pull/3975) by [@pbnjay](https://github.com/pbnjay)
- Fixed more binding and typescript export bugs [PR](https://github.com/wailsapp/wails/pull/3978) by [@pbnjay](https://github.com/pbnjay)
- Fixed Dispatcher.ProcessMessage crash process instead of return error [PR](https://github.com/wailsapp/wails/pull/4016) [#4015](https://github.com/wailsapp/wails/issues/4015) by [@ronaldinho_x86](https://github.com/RonaldinhoL)
### Changed
- Allow to specify macos-min-version externally. Implemented by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/3756)