{"record":{"id":"3620bd8db275e752","repo":"appsmithorg/appsmith","slug":"unable-to-determine-a-unique-accessor","errorCode":null,"errorMessage":"Unable to determine a unique accessor","messagePattern":"Unable to determine a unique accessor","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/client/src/workers/Evaluation/handlers/jsLibrary.ts","lineNumber":222,"sourceCode":"        if (module && typeof module === \"object\") {\n          const uniqAccessor = generateUniqueAccessor(\n            url,\n            takenAccessors,\n            takenNamesMap,\n          );\n\n          self[uniqAccessor] = flattenModule(module);\n          accessors.push(uniqAccessor);\n        }\n      } catch (e) {\n        log.debug(e, `dynamic import failed for ${url}`);\n        throw new ImportError(url);\n      }\n    }\n\n    // If no accessors at this point, installation likely failed.\n    if (accessors.length === 0) {\n      throw new Error(\"Unable to determine a unique accessor\");\n    }\n\n    // Name of the library is the last accessor. This is totally random and needs fixing.\n    const name = accessors[accessors.length - 1];\n\n    defs[\"!name\"] = `LIB/${name}`;\n    try {\n      for (const key of accessors) {\n        defs[key] = makeTernDefs(self[key]);\n      }\n    } catch (e) {\n      for (const acc of accessors) {\n        self[acc] = undefined;\n      }\n\n      log.debug(e, `ternDefinitions failed for ${url}`);\n      throw new TernDefinitionError(\n        `Failed to generate autocomplete definitions: ${name}`,","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/client/src/workers/Evaluation/handlers/jsLibrary.ts#L204-L240","documentation":"Thrown as a plain Error('Unable to determine a unique accessor') in installLibrary when, after attempting importScripts and the dynamic-import fallback, the accessors array is still empty. An empty accessors array means the script loaded without exposing any new global on self and no ESM module object was produced, so Appsmith has no name under which to expose the library to bindings.","triggerScenarios":"Installing a script that runs but attaches nothing to the global scope (e.g. an IIFE that only registers a service worker, or a module whose exports were all consumed internally); a script that threw silently after load; an ESM module that resolved to a falsy/non-object value so the `if (module && typeof module === 'object')` branch was skipped.","commonSituations":"Adding a meta/polyfill script that has no export; choosing the wrong entry file (e.g. a worker bootstrap instead of the library bundle); a script that detects a non-browser context and bails out without defining globals.","solutions":["Use the library's UMD/IIFE bundle that assigns to window/globalThis, or an ESM build that exports its API.","Point at the documented distribution file (dist/*.min.js or the +esm CDN variant) rather than a source/entry file.","Verify in a browser console that loading the script actually defines a global (e.g. window._ or window.dayjs).","If the library is ESM-only, prefer the jsDelivr +esm URL so the dynamic-import path produces a module object."],"exampleFix":"// before\nhttps://cdn.jsdelivr.net/npm/some-polyfill/init.js  // no global exported\n\n// after\nhttps://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js  // defines window._","handlingStrategy":"validation","validationCode":"// Before installing, sanity-check that the script defines a global export.\n// (Quick client-side check - not a guarantee the worker agrees.)\nasync function exposesGlobal(url) {\n  const before = Object.keys(window);\n  try {\n    await import(/* webpackIgnore: true */ url);\n  } catch {\n    try { await new Promise((res, rej) =>\n      importScripts(url) ? res() : rej()); } catch { return false; }\n  }\n  return Object.keys(window).some(k => !before.includes(k));\n}","typeGuard":"const hasExportedAccessor = async (url) => {\n  const before = new Set(Object.keys(globalThis));\n  try { await import(url); } catch { return false; }\n  return Object.keys(globalThis).some(k => !before.has(k));\n};","tryCatchPattern":"try {\n  await installLibrary(url);\n} catch (e) {\n  if (/unique accessor/i.test(e?.message ?? '')) {\n    showToast('That script did not expose any global. Try a UMD/ESM build.');\n  } else throw e;\n}","preventionTips":["Use a build that assigns to globalThis/window (UMD/IIFE) or exports an object (ESM).","Point at the documented dist file, not a source or worker-bootstrap file.","Verify in a browser console that loading the script defines a usable global.","For ESM-only libs, use the jsDelivr +esm URL so a module object is produced."],"tags":["js-library","evaluation","import","accessor"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}