-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Copy link
Labels
Description
When using Deno 1.36.3 I get this Uncaught (in promise) Error: read UNKNOWN
error when running the script below:
error: Uncaught (in promise) Error: read UNKNOWN
at createConnection (file:///home/u/node-vs-deno-db-drivers/node_modules/.deno/mysql2@3.6.0/node_modules/mysql2/promise.js:253:31)
at file:///home/u/node-vs-deno-db-drivers/mysql2.ts:12:28
at file:///home/u/node-vs-deno-db-drivers/mysql2.ts:21:1
When using Deno 1.36.1 (which precedes #20120) I get an Uncaught Error: tlssock._start is not a function
error when running the script:
error: Uncaught Error: tlssock._start is not a function
at createConnection (file:///home/u/node-vs-deno-db-drivers/node_modules/.deno/mysql2@3.6.0/node_modules/mysql2/promise.js:253:31)
at file:///home/u/node-vs-deno-db-drivers/mysql2.ts:12:28
at file:///home/u/node-vs-deno-db-drivers/mysql2.ts:21:1
Given that the stack trace indicates the Error: read UNKNOWN
error is being thrown from the same place as the Uncaught Error: tlssock._start is not a function
error was, I'm thinking it may be a TLS-related issue in Deno.
I've tested the script below with Node v18.17.1
and it runs fine.
How to reproduce
Create mysql2.ts
:
// Swap the commenting on these two lines if you're testing this on Node.js vs Deno
import { createConnection } from "npm:mysql2@^3.6.0/promise"; // For Deno
// import { createConnection } from "mysql2/promise"; // For Node.js
import { readFileSync } from "node:fs";
const cert = readFileSync("/etc/ssl/certs/ca-certificates.crt"); // I'm using Ubuntu - this certificate path may be different for your OS
const planetscaleMysqlUrl = "SOME_MYSQL_URL_HERE";
(async () => {
const connection = await createConnection({
uri: planetscaleMysqlUrl,
ssl: { ca: cert },
});
const result = await connection.execute("SELECT 1");
console.log(result);
connection.end();
})();
In Deno
Run the script above using Deno 1.36.3: deno run -A mysql2.ts
In Node.js
Using v18.17.1
:
npm init -y
- Add
"type": "module"
to package.json npm install mysql2@3.6.0
- Copy or rename the file to
.js
(it's easier):cp mysql2.ts mysql2.js
- Swap the import comments on lines 2 and 3 of
mysql2.js
node mysql2.js