{"record":{"id":"df4bbea6b2909ad1","repo":"netbirdio/netbird","slug":"engine-is-not-running-df4bbe","errorCode":null,"errorMessage":"engine is not running","messagePattern":"engine is not running","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/android/session.go","lineNumber":283,"sourceCode":"\t}\n\tctx, cancel := context.WithCancel(context.Background())\n\tc.extendCancel = cancel\n\treturn ctx, nil\n}\n\nfunc (c *Client) endExtend() {\n\tc.extendMu.Lock()\n\tdefer c.extendMu.Unlock()\n\tif c.extendCancel != nil {\n\t\tc.extendCancel()\n\t\tc.extendCancel = nil\n\t}\n}\n\nfunc (c *Client) extendAuthSession(ctx context.Context, urlOpener URLOpener, isAndroidTV bool) error {\n\tcfg, cfgPath, cc := c.authSnapshot()\n\tif cfg == nil || cc == nil {\n\t\treturn fmt.Errorf(\"engine is not running\")\n\t}\n\tengine := cc.Engine()\n\tif engine == nil {\n\t\treturn fmt.Errorf(\"engine is not initialized\")\n\t}\n\n\tauthClient, err := auth.NewAuth(ctx, cfg.PrivateKey, cfg.ManagementURL, cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create auth client: %v\", err)\n\t}\n\tdefer authClient.Close()\n\n\t// Passing the config path makes the flow pick up the login_hint: an extend\n\t// renews the session of the account already signed in, so it must not stop to\n\t// offer a choice.\n\ta := NewAuthWithConfig(ctx, cfg, cfgPath)\n\ttokenInfo, err := a.foregroundGetTokenInfo(authClient, urlOpener, isAndroidTV)\n\tif err != nil {","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/android/session.go#L265-L301","documentation":"extendAuthSession starts from an auth snapshot of the running client; when authSnapshot returns nil config or nil connect-client, the engine was never started or has been stopped (for example after logout), so there is no live session to extend. This is a precondition failure about client lifecycle, not a network or IdP problem.","triggerScenarios":"ExtendAuthSession called before the client has started and connected (Status is Idle), after the engine was stopped, or after logout cleared the session — the snapshot has no cfg/cc to renew even though the session deadline may still be displayed.","commonSituations":"UI offering session renewal from a cached deadline after the tunnel went down, racing app startup before the connect loop is up, renew dialog still visible after the user logged out.","solutions":["Only enable session renewal when the client is running and connected — Status() is neither Idle nor NeedsLogin","After a logout or stop, require a full interactive login instead of extend","If it races startup, wait for the connected state before invoking"],"exampleFix":"// before\nclient.ExtendAuthSession(opener, false, listener) // called regardless of client state\n\n// after: gate on the run-loop status\nif s := client.Status(); s != \"Idle\" && s != \"NeedsLogin\" {\n\tclient.ExtendAuthSession(opener, false, listener)\n}","handlingStrategy":"validation","validationCode":"// Gate the renew action on the run-loop status before calling\nString s = client.Status();\nif (!\"Idle\".equals(s) && !\"NeedsLogin\".equals(s)) {\n\tclient.ExtendAuthSession(opener, isTV, listener);\n}","typeGuard":"fun canExtendSession(status: String): Boolean = status != \"Idle\" && status != \"NeedsLogin\"","tryCatchPattern":"// In the ErrListener of ExtendAuthSession\nfunc (l *extendListener) OnError(err error) {\n\tif strings.Contains(err.Error(), \"engine is not running\") {\n\t\t// precondition failure: start/connect the client, or offer a full login instead\n\t\treturn\n\t}\n\tl.show(err)\n}","preventionTips":["Enable session-renewal UI only when Status() shows a connected client","After logout or engine stop, route the user to a full login, not extend","Avoid racing startup: wait for the connect loop to report before showing renew controls"],"tags":["android","go","session","engine","lifecycle"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}