{"record":{"id":"51a18f5c341fb11d","repo":"neoclide/coc.nvim","slug":"error-on-loadextension-res-reason","errorCode":null,"errorMessage":"Error on loadExtension ${res.reason}","messagePattern":"Error on loadExtension (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/extension/manager.ts","lineNumber":316,"sourceCode":"    return extension.isActive === true\n  }\n\n  public async deactivate(id: string): Promise<void> {\n    let item = this.extensions.get(id)\n    if (!item || !item.extension.isActive) return\n    await Promise.resolve(item.deactivate())\n  }\n\n  /**\n   * Load extension from folder, folder should contains coc extension.\n   */\n  public async loadExtension(folder: string | string[], noActive = false): Promise<boolean> {\n    if (Array.isArray(folder)) {\n      let results = await Promise.allSettled(folder.map(f => {\n        return this.loadExtension(f, noActive)\n      }))\n      results.forEach(res => {\n        if (res.status === 'rejected') throw new Error(`Error on loadExtension ${res.reason}`)\n      })\n      return true\n    }\n    let errors: string[] = []\n    let obj = loadExtensionJson(folder, workspace.version, errors)\n    if (errors.length > 0) throw new Error(errors[0])\n    let { name } = obj\n    if (this.states.isDisabled(name)) return false\n    // unload if loaded\n    await this.unloadExtension(name)\n    let isLocal = !this.states.hasExtension(name)\n    if (isLocal) this.states.addLocalExtension(name, folder)\n    await this.registerExtension(folder, Object.freeze(obj), isLocal ? ExtensionType.Local : ExtensionType.Global, noActive)\n    return true\n  }\n\n  /**\n   * Deactivate & unregist extension","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/extension/manager.ts#L298-L334","documentation":"loadExtension in src/extension/manager.ts, when given an array of folders, loads them with Promise.allSettled and, if any sub-load rejected, rethrows `Error on loadExtension <reason>`. Only the first rejection is thrown and the remaining results are still iterated; the original rejection reason is embedded as a string, so it is wrapped context rather than the original error object.","triggerScenarios":"Calling loadExtension(['dirA','dirB',...]) where at least one directory fails to load — e.g. missing package.json/extension JSON, invalid JSON (errors from loadExtensionJson), or a nested loadExtension rejection.","commonSituations":"A folder in coc.extensions or the extension root was deleted/renamed; a broken extension among many installed; passing a file path instead of a folder directory.","solutions":["Read the embedded reason to identify which folder failed, then fix that folder (missing or invalid package.json/extension JSON)","Validate each folder contains a loadable extension manifest before batching","Call loadExtension per folder in a loop with individual try/catch to get precise errors and keep loading the rest","Reinstall or remove the broken extension directory"],"exampleFix":"// before\nawait manager.loadExtension(folders) // one bad folder aborts with wrapped error\n// after\nfor (const f of folders) {\n  try { await manager.loadExtension(f) } catch (e) { logger.error(`skip ${f}:`, e) }\n}","handlingStrategy":"try-catch","validationCode":"const ok = folders.every(f => fs.existsSync(path.join(f, 'package.json')))","typeGuard":null,"tryCatchPattern":"try {\n  await manager.loadExtension(folders)\n} catch (e) {\n  if (e.message.startsWith('Error on loadExtension')) {\n    logger.error(`one folder failed: ${e.message}`)\n  } else throw e\n}","preventionTips":["Load folders individually when partial failure is acceptable","Validate each folder has a loadable manifest before batch loading","Keep extension directories intact — avoid partial deletes/renames","Log the embedded reason string to find the failing folder"],"tags":["extension-loading","batch","promise-rejection"],"backgroundTag":"extension-load-failed","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}