{"record":{"id":"0ed357d775cebbcc","repo":"tailscale/tailscale","slug":"clearing-serve-config-w","errorCode":null,"errorMessage":"clearing serve config: %w","messagePattern":"clearing serve config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tsnet/tsnet.go","lineNumber":601,"sourceCode":"\t\t}\n\t\tif st := n.State; st != nil {\n\t\t\tif *st == ipn.Running {\n\t\t\t\tstatus, err := lc.Status(ctx)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"tsnet.Up: %w\", err)\n\t\t\t\t}\n\t\t\t\tif len(status.TailscaleIPs) == 0 {\n\t\t\t\t\treturn nil, errors.New(\"tsnet.Up: running, but no ip\")\n\t\t\t\t}\n\n\t\t\t\t// The first time Up is run, clear the persisted serve config\n\t\t\t\t// and Service advertisements. We do this to prevent messy\n\t\t\t\t// interactions with stale config in the face of code changes.\n\t\t\t\tvar srvCfgErr error\n\t\t\t\tvar svcAdErr error\n\t\t\t\ts.resetServeStateOnce.Do(func() {\n\t\t\t\t\tif err := lc.SetServeConfig(ctx, new(ipn.ServeConfig)); err != nil {\n\t\t\t\t\t\tsrvCfgErr = fmt.Errorf(\"clearing serve config: %w\", err)\n\t\t\t\t\t}\n\t\t\t\t\t_, err := s.lb.EditPrefs(&ipn.MaskedPrefs{\n\t\t\t\t\t\tAdvertiseServicesSet: true,\n\t\t\t\t\t\tPrefs: ipn.Prefs{\n\t\t\t\t\t\t\tAdvertiseServices: []string{},\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tsvcAdErr = fmt.Errorf(\"clearing Service advertisements: %w\", err)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tif err := errors.Join(srvCfgErr, svcAdErr); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"tsnet.Up: %w\", err)\n\t\t\t\t}\n\n\t\t\t\treturn status, nil\n\t\t\t}\n\t\t\t// TODO: in the future, return an error on ipn.NeedsLogin","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/tailscale/tailscale/blob/57c3357fdb542d26c6f9e9f0b815ae5077e63d77/tsnet/tsnet.go#L583-L619","documentation":"On the first successful Up, tsnet resets the persisted serve config to an empty one to avoid stale handlers from earlier runs. The SetServeConfig call to the local API failed, so old serve entries may still be in effect.","triggerScenarios":"Thrown at tsnet/tsnet.go:573 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the local API failure reason","Delete stale serve config from the state directory if it is corrupt","Retry Up once the backend is stable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57c3357fdb542d26c6f9e9f0b815ae5077e63d77","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}