Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin loading is incorrectly memoized #13235

Closed
thorn0 opened this issue Aug 6, 2022 · 1 comment
Closed

Plugin loading is incorrectly memoized #13235

thorn0 opened this issue Aug 6, 2022 · 1 comment
Assignees
Labels
area:api Issues with Prettier's Application Programming Interface area:plugin api locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@thorn0
Copy link
Member

thorn0 commented Aug 6, 2022

Environments:

  • Prettier Version: next
  • Running Prettier via: API
  • Runtime: Node 18
  • Operating System: WSL
  • Prettier plugins (if any): custom

Steps to reproduce:

import * as prettier from "prettier";

console.log(
  await prettier.format(".", {
    plugins: [
      { parsers: { baz: { parse: () => ({}), astFormat: "baz-ast" } } },
      { printers: { "baz-ast": { print: () => "1" } } },
    ],
    parser: "baz",
  }),
  await prettier.format(".", {
    plugins: [
      { parsers: { baz: { parse: () => ({}), astFormat: "baz-ast" } } },
      { printers: { "baz-ast": { print: () => "2" } } },
    ],
    parser: "baz",
  })
);

The problem is here:

const memoizedLoad = mem(load, { cacheKey: JSON.stringify });

Both plugins are serialized to the same string by JSON.stringify.

Expected output: 1 2

Actual output: 1 1

@thorn0 thorn0 added type:bug Issues identifying ugly output, or a defect in the program area:api Issues with Prettier's Application Programming Interface area:plugin api labels Aug 6, 2022
@fisker fisker mentioned this issue Mar 24, 2023
4 tasks
@fisker fisker self-assigned this Mar 24, 2023
@fisker
Copy link
Member

fisker commented Apr 4, 2023

Fixed by #14576

@fisker fisker closed this as completed Apr 4, 2023
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:api Issues with Prettier's Application Programming Interface area:plugin api locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants