got icon indicating copy to clipboard operation
got copied to clipboard

Error when migrating to ESM version

Open Stanzilla opened this issue 1 year ago • 16 comments

Describe the bug

I'm upgrading from v12 to v14 and getting an error that sounds ESM related

  • Node.js version: 22.1.0
  • OS & version: macOS 14.5

Actual behavior

Uncaught TypeError: Class extends value #<Object> is not a constructor or null
    at node_modules/keyv/src/index.js (index.js:37:1)
    at __require2 (chunk-ZDU32GKS.js?v=ae90ae8d:19:50)
    at index.ts:10:18

Looking at the stack trace suggests that it might come from cachable-request which got uses version 10.2.14 of. There is v12 these days and v11 mentions updates for modern node versions, so maybe that's already it? https://github.com/jaredwray/cacheable/releases/tag/v11.0.0

Electron-2024-05-15-03 05 17

Expected behavior

No error ...

Code to reproduce

...

Checklist

  • [x] I have read the documentation.
  • [x] I have tried my code with the latest version of Node.js and Got.

Stanzilla avatar May 15 '24 01:05 Stanzilla

I have updated the dependency: https://github.com/sindresorhus/got/releases/tag/v14.3.0

sindresorhus avatar May 18 '24 13:05 sindresorhus

Hrm still getting the error so probably wasn't that :/

Stanzilla avatar May 18 '24 21:05 Stanzilla

It might need this? https://github.com/jaredwray/keyv/commit/bc130da559f5a0f6d47ac868f0449ff6a66fb166

Stanzilla avatar May 20 '24 10:05 Stanzilla

@Stanzilla - it could need that as it is on kevy@next as it is part of version 5.0.0 that is not out of release candidate until end of June.

jaredwray avatar Jun 05 '24 13:06 jaredwray

@Stanzilla - it could need that as it is on kevy@next as it is part of version 5.0.0 that is not out of release candidate until end of June.

Ah thank you! Do you have a rough ETA?

Stanzilla avatar Jul 02 '24 23:07 Stanzilla

@Stanzilla you can try it now. It will be fully released in the next couple weeks

jaredwray avatar Jul 03 '24 00:07 jaredwray

Just for tracking, keyv 5 is out now, we just need https://github.com/jaredwray/cacheable/blob/main/packages/cacheable-request/package.json to update to it as well now, then update it in got

Stanzilla avatar Aug 26 '24 00:08 Stanzilla

@Stanzilla - it is released and we are working on updating all of our systems. This is a breaking change so might take a bit to get it updated and live in cacheable-request

jaredwray avatar Aug 26 '24 16:08 jaredwray

@Stanzilla - we are planning that this will be released this month. Just FYI. @sindresorhus this could be a bit breaking as we no longer support the uri being passed.

jaredwray avatar Sep 11 '24 14:09 jaredwray

@Stanzilla - https://www.npmjs.com/package/cacheable-request has been released with Keyv v5. 🎉 The major change is that you can no longer pass the uri as a string.

jaredwray avatar Oct 22 '24 15:10 jaredwray

@sindresorhus any issues with updating the dependency on cacheable-request to 13? https://github.com/sindresorhus/got/blob/main/package.json#L54

isaac-martin avatar Jan 27 '25 23:01 isaac-martin

@jaredwray The release notes for cacheable-request are unfortunately not very usable. There is no way to know which release corresponds to v13, and breaking changes are not clearly listed. An automated list of commits is usually not a very user-friendly way to do release notes.

sindresorhus avatar Jan 28 '25 05:01 sindresorhus

@sindresorhus - agreed and I am working on a way to do this better from a mono repo. I did post before what the change was but happy to reiterate these changes:

Cacheable Request v13

Keyv has been updated to version 5. With this update, you can no longer pass in a connection string directly to the CacheableRequest constructor. Instead, you should pass in a Keyv or Keyv storage adapter instance.

import KeyvRedis from '@keyv/redis';
import CacheableRequest from 'cacheable-request';

const keyvRedis = new KeyvRedis('redis://localhost:6379');
const cacheableRequest = new CacheableRequest(http.request, KeyvRedis).createCacheableRequest();

Sorry for the hassle and yes we will start doing better release notes this year.

jaredwray avatar Feb 03 '25 19:02 jaredwray

Hey @Stanzilla have you been able to fix this? I'm getting the same error.

FrancoCanzani avatar May 06 '25 06:05 FrancoCanzani

Hey @Stanzilla have you been able to fix this? I'm getting the same error.

Hey there! No, that will depend on Sindre's time to implement the changes needed to upgrade the version

Stanzilla avatar May 06 '25 11:05 Stanzilla

Hey @Stanzilla have you been able to fix this? I'm getting the same error.

Hey there! No, that will depend on Sindre's time to implement the changes needed to upgrade the version

@sindresorhus 🙏🙏

FrancoCanzani avatar May 06 '25 14:05 FrancoCanzani