prettier/prettier · error · Error

printer.embed has too many parameters. The API changed in Pr

Error message

printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed

What it means

In Prettier v3 the `embed` API changed: it now takes `(path, options)` and returns a function, instead of v2's `(path, print, textToDoc, options)`. The multiparser checks `embed.length > 2` (src/main/multiparser.js:26) and throws immediately so outdated plugins fail fast with an actionable migration message.

Source

Thrown at src/main/multiparser.js:26

  /** @type {AstPath} */ path,
  genericPrint,
  options,
  printAstToDoc,
  embeds,
) {
  if (options.embeddedLanguageFormatting !== "auto") {
    return;
  }

  const { printer } = options;
  const { embed } = printer;

  if (!embed) {
    return;
  }

  if (embed.length > 2) {
    throw new Error(
      "printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed",
    );
  }

  const { hasPrettierIgnore } = printer;
  const { getVisitorKeys } = embed;

  const embedCallResults = [];

  recurse();

  const originalPathStack = path.stack;

  for (const { print, node, pathStack } of embedCallResults) {
    try {
      path.stack = pathStack;
      const doc = await print(textToDocForEmbed, genericPrint, path, options);

View on GitHub (pinned to 315f281982)

Solutions

  1. Upgrade the plugin to a Prettier v3-compatible release.
  2. If you own the plugin, rewrite embed to the v3 signature: `embed(path, options)` returning an async `(textToDoc) => doc` function.
  3. Temporarily remove the incompatible plugin until it ships a v3 build.
  4. Verify the plugin's peerDependencies declare prettier 3 support.

Example fix

// before (v2 embed)
function embed(path, print, textToDoc, options) {
  // ...
}

// after (v3 embed)
function embed(path, options) {
  return async (textToDoc) => {
    // ...
  };
}
Defensive patterns

Strategy: validation

Validate before calling

// Reject plugins with an outdated embed signature before registering them
function isV3CompatiblePlugin(plugin) {
  for (const printer of Object.values(plugin?.printers ?? {})) {
    const embed = printer?.embed;
    if (typeof embed === "function" && embed.length > 2) return false;
  }
  return true;
}

Prevention

When it happens

Trigger: Loading a Prettier v2 plugin whose printer.embed declares 3 or 4 parameters into a Prettier v3 host. Common when upgrading an app to Prettier 3 while a community plugin has not published a v3-compatible release.

Common situations: Major-version Prettier upgrade with stale plugins; plugin peerDependencies still pinned to prettier 2.

Related errors


AI-assisted analysis of prettier/prettier@315f281982 (2026-08-03). Data as JSON: /data/errors/5c7f7cd026c4bf45.json. Report an issue: GitHub.