p-memoize: 4.0.2 is broken?

Am I mistaken, or are all releases between 4.0.2 up to 6.0.0 broken? I was running 4.0.1 for a long time in production with good results, but today when measuring some caching metrics I realized I had lots of misses. Turns out this commit breaks the caching of promises by calling await on the returned promise before putting it in the cache. Am I right? I realize this is not a big deal since it IS fixed in 6.0.0, but perhaps put a note on the Readme or something to stay away from 4.0.2 and 5.x? Can you even revert the 4.0.2 release so that ^4.0.1 in package.json does not pick it up?

(BTW I had severe problems going to 6.0 due to the ESM change. I can’t for my life get tsconfig to play ball when this module uses ESM. Still struggling…)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

@fregante I don’t disagree, but there’s also a risk to just revert to 4.0.1.

Would backporting https://github.com/sindresorhus/p-memoize/commit/343ac6e71a77031a69f9e52bf03ea40e1cfdcbc8 work for anyone? That seems like a less risky change.

@sindresorhus is it possible to backport fixes from https://github.com/sindresorhus/p-memoize/commit/343ac6e71a77031a69f9e52bf03ea40e1cfdcbc8 to 4.0.3?

I agree with @fregante, people rarely read through all install logs, and just switching to >= 5.0.0 is not convenient for projects where ESM is not fully embraced.

Not to mention that “stay on 4.0.1” means manually editing every package.json that uses “^4.0.0”

Right, but that works only for Node >= 12 if I’m correct?

Node.js 14. So it’s a good solution if you’re not making reusable packages.

Who reads npm install logs? They’re so noisy. Leaving a broken version as HEAD of v4 is not great practice, especially if the solution is just republishing 4.0.1 as 4.0.3 (even if breaking for the 1 user who depends on the new behavior, it’s not breaking for literally everyone else)

I think the issue is only with v4.0.2, as from what I can remember, it was fixed in v5.0.0: https://github.com/sindresorhus/p-memoize/commit/343ac6e71a77031a69f9e52bf03ea40e1cfdcbc8