{"record":{"id":"c0f2c0fb831da1e2","repo":"ovity/octotree","slug":"promisify-fn-does-not-have-method-method","errorCode":null,"errorMessage":"promisify: fn does not have ${method} method","messagePattern":"promisify: fn does not have (.+?) method","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core.storage.js","lineNumber":156,"sourceCode":"            'If the local storage for this domain is full, please clean it up and try again.';\n          console.error(msg, e);\n        }\n        resolve();\n      }\n    });\n  }\n\n  _removeLocal (key) {\n    return new Promise((resolve) => {\n      localStorage.removeItem(key);\n      resolve();\n    });\n  }\n}\n\nfunction promisify(fn, method) {\n  if (typeof fn[method] !== 'function') {\n    throw new Error(`promisify: fn does not have ${method} method`);\n  }\n\n  return function(...args) {\n    return new Promise(function(resolve, reject) {\n      fn[method](...args, function(res) {\n        if (chrome.runtime.lastError) {\n          reject(chrome.runtime.lastError);\n        } else {\n          resolve(res);\n        }\n      });\n    });\n  };\n}\n\nwindow.extStore = new ExtStore(STORE, DEFAULTS)\n","sourceCodeStart":138,"sourceCodeEnd":173,"githubUrl":"https://github.com/ovity/octotree/blob/470747c7007c8335981ea7a10a631bbf9bbb11f7/src/core.storage.js#L138-L173","documentation":"promisify(fn, method) in core.storage.js wraps a callback-style storage backend (chrome.storage-based class) into a Promise API by checking that fn has the given method before wrapping it. If the passed object lacks the method, it throws 'promisify: fn does not have <method> method' synchronously from the storage controller constructor.","triggerScenarios":"The storage controller constructor calls promisify(fn, 'get'|'set'|'remove'|...) with a backend object that is missing one of the required methods — e.g. a custom/partial storage implementation, a wrongly injected dependency, or a renamed method after a chrome.* API or version change.","commonSituations":"Implementing a custom storage backend (e.g. for Firefox or tests) that omits a required method like remove() or get(); passing the wrong object (undefined/mock) as the storage dependency; an Octotree version bump adding a new promisified method that custom backends don't provide.","solutions":["Implement the missing method on the storage object passed to the constructor (match the exact name in the error message)","Pass the correct storage backend class instance/dependency wiring instead of a partial or mock object","Check for typos or renamed methods between your backend and what promisify expects (get, set, remove, etc.)","Pin/align your custom backend with the version of Octotree in use, adding any newly required methods"],"exampleFix":"// before\nconst store = { get(key, cb) { /* ... */ } };\nnew Storage(store); // throws: promisify: fn does not have set method\n\n// after\nconst store = {\n  get(key, cb) { /* ... */ },\n  set(obj, cb) { /* ... */ },\n  remove(key, cb) { /* ... */ }\n};\nnew Storage(store);","handlingStrategy":"validation","validationCode":"const REQUIRED = ['get', 'set', 'remove'];\nconst missing = REQUIRED.filter((m) => typeof store[m] !== 'function');\nif (missing.length) {\n  throw new Error(`storage backend missing methods: ${missing.join(', ')}`);\n}","typeGuard":"function isValidStorageBackend(fn) {\n  return typeof fn === 'object' && fn !== null &&\n    ['get', 'set', 'remove'].every((m) => typeof fn[m] === 'function');\n}","tryCatchPattern":"let storage;\ntry {\n  storage = new Storage(backend);\n} catch (err) {\n  if (/^promisify: fn does not have /.test(err.message)) {\n    console.error('Storage backend is missing a required method:', err.message);\n    storage = new Storage(chromeStorageFallback);\n  } else { throw err; }\n}","preventionTips":["Validate the backend object implements every method the storage class promisifies before constructing it","Keep custom storage backends (tests, Firefox port) in sync with the method set expected by core.storage.js","Check exact method names in the error message — they reveal which dependency is incomplete","Watch for Octotree updates that add new promisified storage methods"],"tags":["promisify","storage","missing-method","dependency-injection"],"backgroundTag":"missing-method-on-object","analyzedSha":"470747c7007c8335981ea7a10a631bbf9bbb11f7","analyzedAt":"2026-08-31T23:37:12.882Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}