fix(cef): move MaybeExitSubprocess to main() before Cobra
CEF re-launches the binary with --type=renderer for subprocesses. Previously MaybeExitSubprocess ran inside NewEngine, after Cobra had already parsed and stripped args. Now runs at top of main() when DUMBER_ENGINE=cef, before any arg processing. Also adopts NewClient returning Client directly (no more clientAdapter).
- commit
- 577c40419a15aeff1455cf8d1c5c58aec9f31831
- author
- brice · · 2026-03-19 19:25 UTC
- committer
- brice · · 2026-03-28 04:36 UTC
- parent
- 2ccf5f3
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +11 -1
M cmd/dumber/main.go +9 -0
| @@ -34,6 +34,7 @@ import ( | |||
| 34 | 34 | "github.com/bnema/dumber/internal/ui/adapter" | |
| 35 | 35 | "github.com/bnema/dumber/internal/ui/component" | |
| 36 | 36 | "github.com/bnema/dumber/internal/ui/theme" | |
| 37 | + | cef "github.com/bnema/purego-cef/cef" | |
| 37 | 38 | "github.com/bnema/puregotk/v4/gtk" | |
| 38 | 39 | "github.com/rs/zerolog" | |
| 39 | 40 | ) | |
| @@ -54,6 +55,14 @@ var restoreSessionID string | |||
| 54 | 55 | func main() { | |
| 55 | 56 | enableCrashForensics() | |
| 56 | 57 | ||
| 58 | + | // CEF subprocess handling: when CEF re-launches the binary with | |
| 59 | + | // --type=renderer/gpu/etc, we must call ExecuteProcess before anything | |
| 60 | + | // else (Cobra, config, arg stripping). This only runs when the engine | |
| 61 | + | // is set to "cef" and exits immediately for subprocess invocations. | |
| 62 | + | if os.Getenv("DUMBER_ENGINE") == "cef" { | |
| 63 | + | cef.MaybeExitSubprocess() | |
| 64 | + | } | |
| 65 | + | ||
| 57 | 66 | // Run GUI mode for browse command | |
| 58 | 67 | if len(os.Args) > 1 && os.Args[1] == "browse" { | |
| 59 | 68 | if len(os.Args) > 2 { | |
| @@ -34,6 +34,7 @@ import ( | |||||
| 34 | "github.com/bnema/dumber/internal/ui/adapter" | 34 | "github.com/bnema/dumber/internal/ui/adapter" | ||
| 35 | "github.com/bnema/dumber/internal/ui/component" | 35 | "github.com/bnema/dumber/internal/ui/component" | ||
| 36 | "github.com/bnema/dumber/internal/ui/theme" | 36 | "github.com/bnema/dumber/internal/ui/theme" | ||
| 37 | + | cef "github.com/bnema/purego-cef/cef" | |||
| 37 | "github.com/bnema/puregotk/v4/gtk" | 38 | "github.com/bnema/puregotk/v4/gtk" | ||
| 38 | "github.com/rs/zerolog" | 39 | "github.com/rs/zerolog" | ||
| 39 | ) | 40 | ) | ||
| @@ -54,6 +55,14 @@ var restoreSessionID string | |||||
| 54 | func main() { | 55 | func main() { | ||
| 55 | enableCrashForensics() | 56 | enableCrashForensics() | ||
| 56 | 57 | ||||
| 58 | + | // CEF subprocess handling: when CEF re-launches the binary with | |||
| 59 | + | // --type=renderer/gpu/etc, we must call ExecuteProcess before anything | |||
| 60 | + | // else (Cobra, config, arg stripping). This only runs when the engine | |||
| 61 | + | // is set to "cef" and exits immediately for subprocess invocations. | |||
| 62 | + | if os.Getenv("DUMBER_ENGINE") == "cef" { | |||
| 63 | + | cef.MaybeExitSubprocess() | |||
| 64 | + | } | |||
| 65 | + | ||||
| 57 | // Run GUI mode for browse command | 66 | // Run GUI mode for browse command | ||
| 58 | if len(os.Args) > 1 && os.Args[1] == "browse" { | 67 | if len(os.Args) > 1 && os.Args[1] == "browse" { | ||
| 59 | if len(os.Args) > 2 { | 68 | if len(os.Args) > 2 { | ||
M internal/infrastructure/cef/engine_init.go +2 -1
| @@ -22,7 +22,8 @@ func NewEngine(ctx context.Context, cfg config.CEFEngineConfig, logger zerolog.L | |||
| 22 | 22 | settings.LogSeverity = cfg.LogSeverity | |
| 23 | 23 | } | |
| 24 | 24 | ||
| 25 | - | purecef.MaybeExitSubprocess() | |
| 25 | + | // NOTE: MaybeExitSubprocess is called in main() before Cobra, so that | |
| 26 | + | // CEF subprocess args (--type=renderer) are handled before arg stripping. | |
| 26 | 27 | ||
| 27 | 28 | if err := purecef.Init(settings); err != nil { | |
| 28 | 29 | return nil, fmt.Errorf("cef.Init: %w", err) | |
| @@ -22,7 +22,8 @@ func NewEngine(ctx context.Context, cfg config.CEFEngineConfig, logger zerolog.L | |||||
| 22 | settings.LogSeverity = cfg.LogSeverity | 22 | settings.LogSeverity = cfg.LogSeverity | ||
| 23 | } | 23 | } | ||
| 24 | 24 | ||||
| 25 | - | purecef.MaybeExitSubprocess() | 25 | + | // NOTE: MaybeExitSubprocess is called in main() before Cobra, so that |
| 26 | + | // CEF subprocess args (--type=renderer) are handled before arg stripping. | |||
| 26 | 27 | ||||
| 27 | if err := purecef.Init(settings); err != nil { | 28 | if err := purecef.Init(settings); err != nil { | ||
| 28 | return nil, fmt.Errorf("cef.Init: %w", err) | 29 | return nil, fmt.Errorf("cef.Init: %w", err) | ||