{"record":{"id":"048015ec2553f3a3","repo":"tailscale/tailscale","slug":"clearing-service-advertisements-w","errorCode":null,"errorMessage":"clearing Service advertisements: %w","messagePattern":"clearing Service advertisements: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tsnet/tsnet.go","lineNumber":610,"sourceCode":"\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\n\t\t\t// and ipn.NeedsMachineAuth to improve the UX of trying\n\t\t\t// out the tsnet package.\n\t\t\t//\n\t\t\t// Unfortunately today, even when using an AuthKey we\n\t\t\t// briefly see these states. It would be nice to fix.\n\t\t}\n\t}\n}\n","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/tailscale/tailscale/blob/57c3357fdb542d26c6f9e9f0b815ae5077e63d77/tsnet/tsnet.go#L592-L628","documentation":"On the first successful Up, tsnet clears the AdvertiseServices pref so Service advertisements from previous runs do not persist. The EditPrefs call failed, so stale advertisements may remain visible to the tailnet.","triggerScenarios":"Thrown at tsnet/tsnet.go:582 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error from EditPrefs","Retry Up after the backend settles","Manually clear AdvertiseServices if the state store is corrupt"],"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-14T05:17:10.506Z"}