{"record":{"id":"b64ee3cc6f5a24f3","repo":"RocketChat/Rocket.Chat","slug":"failed-to-save-registration-data","errorCode":null,"errorMessage":"Failed to save registration data","messagePattern":"Failed to save registration data","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/cloud/saveRegistrationData.ts","lineNumber":97,"sourceCode":"\t// we need to make sure that the cache is updated before we continue the procedures\n\t// we don't actually need to wait a whole second for this, but look this is just a retry mechanism it doesn't mean that actually takes all this time\n\tfor (const retry of Array.from({ length: 10 })) {\n\t\tconst isSettingsUpdated =\n\t\t\tsettings.get('Register_Server') === true &&\n\t\t\tsettings.get('Cloud_Workspace_Id') === workspaceId &&\n\t\t\tsettings.get('Cloud_Workspace_Name') === client_name &&\n\t\t\tsettings.get('Cloud_Workspace_Client_Id') === client_id &&\n\t\t\tsettings.get('Cloud_Workspace_Client_Secret') === client_secret &&\n\t\t\tsettings.get('Cloud_Workspace_Client_Secret_Expires_At') === client_secret_expires_at &&\n\t\t\tsettings.get('Cloud_Workspace_PublicKey') === publicKey &&\n\t\t\tsettings.get('Cloud_Workspace_Registration_Client_Uri') === registration_client_uri;\n\n\t\tif (isSettingsUpdated) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (retry === 9) {\n\t\t\tthrow new Error('Failed to save registration data');\n\t\t}\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\t}\n}\n\nexport async function saveRegistrationDataManual({\n\tworkspaceId,\n\tclient_name,\n\tclient_id,\n\tclient_secret,\n\tclient_secret_expires_at,\n\tpublicKey,\n\tregistration_client_uri,\n\tlicenseData,\n}: ManualSaveRegistrationDataDTO) {\n\tawait saveRegistrationDataBase({\n\t\tworkspaceId,","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/cloud/saveRegistrationData.ts#L79-L115","documentation":"saveRegistrationDataBase writes the eight registration settings (Register_Server plus seven Cloud_Workspace_* values) and then re-reads them in a retry loop — up to 10 attempts, one second apart — until settings.get() matches what was written. The loop exists because settings go through a DB/cache roundtrip; if the values still mismatch on the final attempt (retry === 9) it throws 'Failed to save registration data'.","triggerScenarios":"Settings.updateValueById writes silently failing, the settings cache serving stale values for 10+ seconds, or another process overwriting the Cloud_Workspace_* settings between write and verification (e.g. two concurrent registrations flipping values).","commonSituations":"Two admins or tabs registering the workspace at the same time; MongoDB write problems or heavy load slowing cache invalidation; long-running processes with a stale in-memory settings cache.","solutions":["Ensure only one registration flow runs at a time — close other tabs/flows and retry the registration.","Check MongoDB health and inspect the rocketchat_settings documents for the Cloud_Workspace_* keys.","Restart the app to clear a stale settings cache, then re-register.","Inspect logs around the registration for failed settings writes or concurrent modification."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await saveRegistrationData(dto);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to save registration data') {\n    // settings writes not observable after 10s: check for concurrent flows / settings cache, then re-register once\n  }\n  throw e;\n}","preventionTips":["Serialize workspace registration (one admin, one tab) so Cloud_Workspace_* settings are never overwritten mid-verify.","Watch settings cache propagation in monitoring; a loop that always times out indicates stale cache or DB writes failing.","Restart the app after registration anomalies to reset the in-memory settings cache before retrying."],"tags":["rocket-chat","cloud","settings","persistence","retry"],"backgroundTag":"settings-persist-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}