{"record":{"id":"f31b766402014321","repo":"mastra-ai/mastra","slug":"mastra-wrapper-plugin-did-not-return-code-there-i","errorCode":null,"errorMessage":"mastra-wrapper plugin did not return code, there is likely a bug in the plugin.","messagePattern":"mastra-wrapper plugin did not return code, there is likely a bug in the plugin\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/cloudflare/src/plugins/mastra-instance-wrapper.ts","lineNumber":21,"sourceCode":"import { mastraInstanceWrapper as mastraInstanceWrapperBabel } from '../babel/mastra-instance-wrapper';\n\nexport function mastraInstanceWrapper(mastraEntryFile: string): Plugin {\n  return {\n    name: 'mastra-wrapper',\n    transform(code, id) {\n      if (id !== mastraEntryFile) {\n        return null;\n      }\n\n      const result = transformSync(code, {\n        filename: id,\n        babelrc: false,\n        configFile: false,\n        plugins: [mastraInstanceWrapperBabel],\n      });\n\n      if (!result?.code) {\n        throw new Error('mastra-wrapper plugin did not return code, there is likely a bug in the plugin.');\n      }\n\n      return {\n        code: result.code,\n        map: result?.map as SourceMapInput | undefined,\n      };\n    },\n  };\n}\n","sourceCodeStart":3,"sourceCodeEnd":31,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/cloudflare/src/plugins/mastra-instance-wrapper.ts#L3-L31","documentation":"During deployment the Cloudflare deployer transforms your entry code with Babel using the `mastraInstanceWrapperBabel` plugin. If Babel returns a result with no `code`, the transform produced no output, and the deployer aborts with this internal-bug diagnostic. It should never happen in a healthy setup.","triggerScenarios":"Calling `transform()` when the Babel transform with `mastraInstanceWrapperBabel` returns null/undefined or a result without a `code` property (parse failure, incompatible Babel core, or a genuine plugin bug).","commonSituations":"Version mismatch between @mastra/deployers and @babel/core in the consumer's dependency tree; entry-file syntax the Babel config cannot parse; duplicated/corrupted Babel installations; upstream plugin regression.","solutions":["Upgrade @mastra/deployers (and the mastra suite) to the latest patch where the plugin bug may be fixed.","Check for duplicate/mismatched @babel/core versions (`pnpm why @babel/core`) and dedupe so the plugin runs against the Babel core it was built for.","Run the same Babel transform manually on the entry file to expose any parse failure; fix the offending syntax.","Pin a known-good previous deployer version as a workaround and file an upstream issue."],"exampleFix":"// before\nconst result = transform(code, { babelrc: false, configFile: false, plugins: [mastraInstanceWrapperBabel] });\n// after (diagnose which input/plugin fails)\nconst result = transform(code, { babelrc: false, configFile: false, plugins: [mastraInstanceWrapperBabel], filename: 'mastra-entry.ts' });\nif (!result?.code) throw new Error(`transform returned no code; @babel/core version: ${BABEL_VERSION}`);","handlingStrategy":"try-catch","validationCode":"// Validate the entry file parses before trusting the plugin's output\nimport { parse } from '@babel/core';\nfunction canParse(code: string): boolean {\n  try { parse(code, { babelrc: false, configFile: false, sourceType: 'module' }); return true; }\n  catch { return false; }\n}","typeGuard":"function hasTransformCode(r: unknown): r is { code: string; map?: unknown } {\n  return typeof r === 'object' && r !== null && typeof (r as any).code === 'string' && (r as any).code.length > 0;\n}","tryCatchPattern":"try {\n  const out = transformer.transform(code);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('mastra-wrapper plugin did not return code')) {\n    console.error('Babel plugin produced no output. Check @babel/core version match and entry-file syntax.', err);\n  } else throw err;\n}","preventionTips":["Keep @babel/core and @mastra/deployers versions aligned; dedupe duplicate Babel copies in node_modules.","Verify the entry file parses with plain Babel before deploying.","Upgrade to the latest mastra patch releases — this error indicates an internal plugin bug.","Pin a known-good deployer version and file an upstream issue when triggered."],"tags":["babel","plugin","build","deployers"],"backgroundTag":"babel-transform-no-output","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}