{"record":{"id":"1cfab5eabfdd66e9","repo":"hcengineering/platform","slug":"force-close-unknown","errorCode":null,"errorMessage":"force-close-unknown","messagePattern":"force-close-unknown","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"foundations/server/packages/server/src/sessionManager.ts","lineNumber":1191,"sourceCode":"      workspace.maintenance = true\n      ctx.info('force-maintenance', { workspaceId })\n      await this.doCloseAll(workspace, 99, 'force-close')\n    }\n  }\n\n  async forceClose (wsId: WorkspaceUuid, ignoreSocket?: ConnectionSocket): Promise<void> {\n    const ws = this.workspaces.get(wsId)\n    this.maintenanceWorkspaces.delete(wsId)\n    this.workspaceInfoCache.delete(wsId)\n    if (ws !== undefined) {\n      this.ctx.warn('force-close', { name: ws.wsId.url })\n      ws.maintenance = true // We need to similare upgrade to refresh all clients.\n      ws.closing = this.doCloseAll(ws, 99, 'force-close', ignoreSocket)\n      this.workspaces.delete(wsId)\n      await ws.closing\n      ws.closing = undefined\n    } else {\n      this.ctx.warn('force-close-unknown', { wsId })\n    }\n  }\n\n  async doCloseAll (\n    workspace: Workspace,\n    code: number,\n    reason: 'upgrade' | 'shutdown' | 'force-close',\n    ignoreSocket?: ConnectionSocket\n  ): Promise<void> {\n    if (LOGGING_ENABLED) {\n      this.ctx.info('closing workspace', {\n        url: workspace.wsId.url,\n        uuid: workspace.wsId.uuid,\n        code,\n        reason\n      })\n    }\n","sourceCodeStart":1173,"sourceCodeEnd":1209,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/packages/server/src/sessionManager.ts#L1173-L1209","documentation":"Warning emitted by TSessionManager.forceClose when the requested wsId is NOT present in this.workspaces — there is nothing to close on this node. The workspace caches (maintenanceWorkspaces, workspaceInfoCache) are still cleared, so this typically indicates the caller acted on stale state or the workspace lives on another server node.","triggerScenarios":"forceClose(wsId) invoked while this.workspaces.get(wsId) === undefined: workspace already closed/evicted, never loaded on this node, or already force-closed concurrently.","commonSituations":"Double force-close from racing admin operations or a retry; stale workspace registry entry pointing at the wrong node; workspace closed by idle timeout just before the close request arrived.","solutions":["Usually harmless — the caches are cleaned anyway; confirm the workspace is not expected on this node.","Check the workspace service routing: ensure close requests go to the node actually hosting the workspace.","Look for duplicate/concurrent forceClose calls for the same wsId and add idempotency or locking in the caller.","If the workspace should have been present, investigate why it was closed earlier (errors in close path, idle eviction)."],"exampleFix":"// before: fire-and-forget close to any node\nawait Promise.all(nodes.map(n => n.forceClose(wsId)))\n// after: route to the owning node only\nconst owner = await workspaceService.getNode(wsId)\nawait owner.forceClose(wsId)","handlingStrategy":"validation","validationCode":"const loaded = sessionManager.workspaces.get(wsId)\nif (loaded === undefined) {\n  console.warn('workspace not loaded on this node; skip forceClose or route to owner node')\n}","typeGuard":"function isTracked(ws: Workspace | undefined): ws is Workspace {\n  return ws !== undefined\n}","tryCatchPattern":"try {\n  await sessionManager.forceClose(wsId)\n} catch (err) {\n  logger.warn('force-close on unknown workspace is a no-op', { wsId, err })\n}","preventionTips":["Route close requests to the node currently hosting the workspace (query the workspace service registry).","Make close orchestration idempotent so retries don't log spurious unknown-workspace entries.","Refresh the workspace registry after closes to avoid acting on stale routing.","Deduplicate concurrent close requests for the same wsId."],"tags":["force-close","workspace","stale-state","logging"],"backgroundTag":"workspace-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}