question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

f.ClientHandshake is not a constructor

See original GitHub issue

Hi,

When I use the package locally, everything works fine. However, when I use it inside an AWS Lambda function to connect to an RDS instance, I get this cryptic error:

TypeError: f.ClientHandshake is not a constructor
at new g (/var/task/index.js:275:62824)
at new o (/var/task/index.js:275:224046)
at e.exports.getConnection (/var/task/index.js:275:218705)
at e.exports.execute (/var/task/index.js:275:220197)
at /var/task/index.js:275:372341
at new Promise (<anonymous>)
at c.execute (/var/task/index.js:275:372308)
at /var/task/index.js:357:14189
at E (/var/task/index.js:316:24416)
at Generator._invoke (/var/task/index.js:316:24204)

Any idea what the issue is? I’m confident that the roles/security groups are all configured correctly.

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
astrobobcommented, May 30, 2019

Hi @sidorares Unfortunately, I lost a day facing the same issue, but not with AWS. Thanks to https://stackoverflow.com/questions/53524510/mysql2-typeerror-f-clienthandshake-is-not-a-constructor, I finally understood the problem was coming with Webpack as I use typescript.

However, why is this ticket closed? There is still an issue, because as soon as you minify the code for production, your module doesn’t work any more.

Please consider this issue (it might maybe only concern users using Typescript, but still, it’s an issue)

Thank you in advance

3reactions
BarthesSimpsoncommented, Nov 28, 2018

Yes, I’m using Webpack to bundle it. I did just notice I get a warning during the packaging stage that may be related

WARNING in ./node_modules/mysql2/lib/helpers.js
Module not found: Error: Can't resolve 'cardinal' in '<...>/node_modules/mysql2/lib'
 @ ./node_modules/mysql2/lib/helpers.js
 @ ./node_modules/mysql2/lib/parsers/binary_parser.js
 @ ./node_modules/mysql2/lib/commands/execute.js
 @ ./node_modules/mysql2/lib/commands sync ^\.\/.*\.js$
 @ ./node_modules/mysql2/lib/commands/index.js
 @ ./node_modules/mysql2/lib/connection.js
 @ ./node_modules/mysql2/index.js
 @ ./node_modules/mysql2/promise.js
 @ ./src/db/index.js
 @ ./src/db/models/<...>.js
 @ ./src/<...>.js
 @ ./src/<...>/index.js
 @ multi ./src/<...>/index.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

mysql2 TypeError: f.ClientHandshake is not a constructor
Turns out disabling minification in Webpack fixed the issue. This can be done by updating the webpack.config.js to include
Read more >
mysql2 TypeError: f.ClientHandshake is not a constructor
I'm trying to use mysql2 to connect to an RDS MySQL instance. When I use the package ... that the roles/security groups are...
Read more >
TypeError: StoryblokClient is not a constructor : r/webdev
hey, as you can see here storyblokClient is definetly an object, however when I use it like that it throws this error (note:...
Read more >
User BarthesSimpson - Server Fault
mysql2 TypeError: f.ClientHandshake is not a constructor. 9. secure cookies node.js + Heroku + CloudFlare. 8. Longest common subsequence of 3+ strings ...
Read more >
WebSocketAdapter (components 1.1.4 API)
void, onWebsocketHandshakeSentAsClient​(WebSocket conn, ClientHandshake request). This default implementation does not do anything which will cause the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found