{"record":{"id":"ad92c56cc3ba305c","repo":"cube-js/cube","slug":"cannot-check-property-existence-on-instancename","errorCode":null,"errorMessage":"Cannot check property existence on ${instanceName}. The '${name}' has been cleaned up and is no longer available.","messagePattern":"Cannot check property existence on (.+?)\\. The '(.+?)' has been cleaned up and is no longer available\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-shared/src/disposedProxy.ts","lineNumber":26,"sourceCode":"      throw new Error(\n        `Cannot access property '${String(prop)}' on ${instanceName}. ` +\n        `The '${name}' has been cleaned up and is no longer available.`\n      );\n    },\n    set(_target: object, prop: string | symbol): never {\n      throw new Error(\n        `Cannot set property '${String(prop)}' on ${instanceName}. ` +\n        `The '${name}' has been cleaned up and is no longer available.`\n      );\n    },\n    apply(): never {\n      throw new Error(\n        `Cannot call method on ${instanceName}. ` +\n        `The '${name}' has been cleaned up and is no longer available.`\n      );\n    },\n    has(_target: object, _prop: string | symbol): never {\n      throw new Error(\n        `Cannot check property existence on ${instanceName}. ` +\n        `The '${name}' has been cleaned up and is no longer available.`\n      );\n    },\n    ownKeys(): never {\n      throw new Error(\n        `Cannot enumerate properties on ${instanceName}. ` +\n        `The '${name}' has been cleaned up and is no longer available.`\n      );\n    },\n    getPrototypeOf(): never {\n      throw new Error(\n        `Cannot get prototype of ${instanceName}. ` +\n        `The '${name}' has been cleaned up and is no longer available.`\n      );\n    }\n  });\n}","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/disposedProxy.ts#L8-L44","documentation":"The `has` trap of the disposed proxy fires when the `in` operator (or `Reflect.has`) is used against an already-disposed Cube internal. Cube swaps disposed instances for this proxy so any dangling reference fails loudly. Seeing it means code is probing an object that was cleaned up.","triggerScenarios":"Executing `'methodName' in someDisposedInstance` or a feature-check like `if ('foo' in obj)` where obj was replaced by the disposed proxy after its owner's cleanup ran.","commonSituations":"Duck-typing/feature detection on cached Cube internals after dispose; library code defensively checking properties on an object that was torn down; hot-reload leaving stale module-level references.","solutions":["Do not run property-existence checks on instances after their owner has been disposed.","Perform the `in` check before teardown, or re-fetch a live instance reference.","Remove the stale reference when the owner is disposed (set it to null and check before use)."],"exampleFix":"// before\nconst orchestrator = server.orchestrator;\nserver.dispose();\nif ('compileQuery' in orchestrator) { orchestrator.compileQuery(); }\n\n// after\nlet orchestrator = server.orchestrator;\nserver.dispose();\norchestrator = null;\nif (orchestrator && 'compileQuery' in orchestrator) { orchestrator.compileQuery(); }","handlingStrategy":"try-catch","validationCode":"if (objRef == null) {\n  throw new Error('Reference cleared before `in` check.');\n}","typeGuard":"function isUsable<T extends object>(ref: T | null | undefined): ref is T {\n  if (ref == null) return false;\n  try {\n    Object.keys(ref); // throws on disposed proxy via ownKeys\n    return true;\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"let exists = false;\ntry {\n  exists = 'prop' in possiblyDisposed;\n} catch (e) {\n  if (e.message.includes('has been cleaned up')) {\n    exists = false; // treat disposed objects as lacking all props\n  } else {\n    throw e;\n  }\n}","preventionTips":["Do feature detection before teardown, not after.","Clear cached references when the owning component is disposed.","Avoid duck-typing on long-lived Cube internals; use explicit flags instead.","Guard stale references with a null check before any property probe."],"tags":["disposed-object","lifecycle","proxy","cleanup"],"backgroundTag":"use-after-dispose","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}