{"record":{"id":"0e3b6fbd8905b72d","repo":"cube-js/cube","slug":"cannot-get-prototype-of-instancename-the-na","errorCode":null,"errorMessage":"Cannot get prototype of ${instanceName}. The '${name}' has been cleaned up and is no longer available.","messagePattern":"Cannot get prototype of (.+?)\\. 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":38,"sourceCode":"      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}\n","sourceCodeStart":20,"sourceCodeEnd":45,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/disposedProxy.ts#L20-L45","documentation":"The `getPrototypeOf` trap of the disposed proxy fires when code reads the prototype of an already-disposed instance (e.g. instanceof checks, Object.getPrototypeOf, or methods that inspect the prototype chain). Cube throws to expose dangling references to cleaned-up objects rather than returning misleading results.","triggerScenarios":"Performing `x instanceof DriverClass`, Object.getPrototypeOf(x), or any framework plumbing that inspects the prototype of an instance after its owner's dispose() ran.","commonSituations":"Type/instanceof checks on cached Cube internals after shutdown; dependency-injection or logging frameworks that introspect object prototypes; hot-reload leaving stale references that later get introspected.","solutions":["Avoid instanceof/prototype introspection of instances after their owner was disposed.","Re-acquire a live reference before doing type checks.","Null out cached references at disposal time and check before introspecting."],"exampleFix":"// before\nconst driver = server.driverFactory;\nserver.dispose();\nif (driver instanceof PostgresDriver) { driver.release(); }\n\n// after\nlet driver = server.driverFactory;\nserver.dispose();\ndriver = null;\nif (driver instanceof PostgresDriver) { driver.release(); }","handlingStrategy":"try-catch","validationCode":"if (ref == null) {\n  throw new Error('Reference cleared before instanceof check.');\n}","typeGuard":"function isLiveInstance<T extends object>(ref: T | null | undefined): ref is T {\n  if (ref == null) return false;\n  try {\n    void Object.getPrototypeOf(ref); // throws on disposed proxy\n    return true;\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  if (ref instanceof DriverClass) ref.release();\n} catch (e) {\n  if (e.message.includes('has been cleaned up')) {\n    return; // already disposed; nothing to release\n  }\n  throw e;\n}","preventionTips":["Run instanceof/type introspection only while the owner is known to be alive.","Track disposal with your own boolean flag instead of probing the object.","Null out references at dispose time so guards short-circuit on null.","Avoid frameworks/introspection helpers operating on torn-down Cube internals."],"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"}