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

TypeError: LRU is not a constructor #2619

Open
jasmasher opened this issue Apr 24, 2024 · 3 comments
Open

TypeError: LRU is not a constructor #2619

jasmasher opened this issue Apr 24, 2024 · 3 comments

Comments

@jasmasher
Copy link

jasmasher commented Apr 24, 2024

I believe there is a conflict version with the lru-cache package. After some digging noticed that lru-cache v8.0.0 is the only version that exports the class as "default" and that's how is refernced in the code

const LRU = require('lru-cache').default;

but if for some reason there is a version conflict on that library, which in my case happened you get that error. I also noticed that mysql2 has this dependeny "named-placeholders": "^1.1.3" but "named-placeholders dependecy is "lru-cache": "^7.14.1".

I'm nort sure why npm is not crying about this but in my case I'm getting lru-cache "5.1.1" which is even worst.

I fixed the issue by manually installing lru-cache v8.0.0

@sidorares
Copy link
Owner

@wellwelwel I bumped lru-cache in named-placeholders ( need to publish it, last release action failed for some reason )

Couple of notes:

  • need to revisit what stops us from using the very latest version ( 10.x now )
  • 8.0.5 exports main class as both main export as well as default export so we may no longer need to require('lru-cache').default
  • maybe remove dependency altogether from named-placeholders and require users to bring your own cache? Would be a major version bump, and we'd need to change mysql2 side to pass cache constructor ( or cache instance ).

@wellwelwel
Copy link
Collaborator

wellwelwel commented Apr 26, 2024

I bumped lru-cache in named-placeholders ( need to publish it, last release action failed for some reason )

Based on named-placeholders error:

✖ Error when creating branch
Error: release-please failed: Error creating Pull Request: Resource not accessible by integration

Possibly that's it:

Settings > Actions > General > Workflow permissions

Screenshot 2024-04-26 at 01 22 45

@wellwelwel
Copy link
Collaborator

wellwelwel commented Apr 26, 2024

need to revisit what stops us from using the very latest version ( 10.x now )

Looking at the LRU Cache breaking changes:

v9

  • Use named export only, no default export.

We could adapt the import.

v10

  • cache.fetch() return type is now Promise<V | undefined> instead of Promise<V | void>. This is an irrelevant change practically speaking, but can require changes for TypeScript users.

It just changes a type (TypeScript) from undefined to void, so it shouldn't affect MySQL2 code 🙋🏻‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants