{"record":{"id":"a8e297941b7577ad","repo":"paperclipai/paperclip","slug":"sandbox-loader-only-supports-commonjs-modules-bui","errorCode":null,"errorMessage":"Sandbox loader only supports CommonJS modules. Build plugin worker entrypoints as CJS for sandboxed loading.","messagePattern":"Sandbox loader only supports CommonJS modules\\. Build plugin worker entrypoints as CJS for sandboxed loading\\.","errorType":"exception","errorClass":"PluginSandboxError","httpStatus":null,"severity":"error","filePath":"server/src/services/plugin-runtime-sandbox.ts","lineNumber":110,"sourceCode":"  const realPluginRoot = realpathSync(pluginRoot);\n\n  const loadModuleSync = (modulePath: string): Record<string, unknown> => {\n    const resolvedPath = resolveModulePathSync(path.resolve(modulePath));\n    const realPath = realpathSync(resolvedPath);\n\n    if (!isWithinRoot(realPath, realPluginRoot)) {\n      throw new PluginSandboxError(\n        `Import '${modulePath}' escapes plugin root and is not allowed`,\n      );\n    }\n\n    const cached = moduleCache.get(realPath);\n    if (cached) return cached;\n\n    const code = readModuleSourceSync(realPath);\n\n    if (looksLikeEsm(code)) {\n      throw new PluginSandboxError(\n        \"Sandbox loader only supports CommonJS modules. Build plugin worker entrypoints as CJS for sandboxed loading.\",\n      );\n    }\n\n    const module = { exports: {} as Record<string, unknown> };\n    // Cache the module before execution to preserve CommonJS cycle semantics.\n    moduleCache.set(realPath, module.exports);\n\n    const requireInSandbox = (specifier: string): Record<string, unknown> => {\n      if (!specifier.startsWith(\".\") && !specifier.startsWith(\"/\")) {\n        if (!allowedSpecifiers.has(specifier)) {\n          throw new PluginSandboxError(\n            `Import denied for module '${specifier}'. Add an explicit sandbox allow-list entry.`,\n          );\n        }\n\n        const binding = allowedModules[specifier];\n        if (!binding) {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/server/src/services/plugin-runtime-sandbox.ts#L92-L128","documentation":"Module-format guard: the module source looks like ESM (import/export syntax), which the synchronous vm sandbox loader cannot execute. Plugin workers must be built as CommonJS for sandboxed loading; the ESM-built entrypoint is at fault.","triggerScenarios":"Thrown at server/src/services/plugin-runtime-sandbox.ts:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Build the plugin worker entrypoint as CommonJS (e.g. tsup/rollup output format 'cjs') so the sandbox loader can require it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}