{"record":{"id":"6a641599689c4d98","repo":"nats-io/nats-server","slug":"unable-to-flush-session-v","errorCode":null,"errorMessage":"unable to flush session: %v","messagePattern":"unable to flush session: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/tpm/js_ek_tpm_windows.go","lineNumber":153,"sourceCode":"sessHandle, policy, err := policyPCRPasswordSession(rwc, pcr)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"unable to get policy: %v\", err)\n}\nif err := tpm2.FlushContext(rwc, sessHandle); err != nil {\n\treturn \"\", fmt.Errorf(\"unable to flush session: %v\", err)\n}\n// Seal the data to the parent key and the policy\nuser, err := nkeys.CreateUser()\nif err != nil {\n\treturn \"\", fmt.Errorf(\"unable to create seed: %v\", err)\n}","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/tpm/js_ek_tpm_windows.go#L135-L171","documentation":"After obtaining the PCR/password policy session, tpm2.FlushContext could not release the session handle in the TPM. The session lingers inside the TPM and consumes a session slot; repeated failures could exhaust the TPM's session resources. The key sealing is aborted to avoid proceeding with stale TPM state.","triggerScenarios":"Thrown at server/tpm/js_ek_tpm_windows.go:153 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped TPM error for resource exhaustion (too many loaded sessions)","Reboot or reset the TPM to clear leaked sessions if slots are exhausted","Retry key creation after the TPM recovers","Upgrade tpm2 library/TPM firmware if FlushContext consistently fails"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}