self-hosted observable-database-proxy crashing

Hello,

I am trying to set up observable-database-proxy to use a self-hosted MySQL database in the Observable notebook environment. The setup appears to go fine, but when using the proxy in Chrome, it crashes with an SSL error (see crash logs below) anytime I attempt to access the database connection. For instance, given a cell called db whose value is a MySQLDatabaseClient, another cell containing db.describe() will cause the crash when it runs. When using Safari, the proxy doesn’t crash, but db.describe() return “TypeError: Load failed.” In the Observable database settings window, I have “Require SSL/TLS” and “Allow guest access” both unselected.

I am using MySQL 9.0.1 running inside a Docker container on MacOS, however I also tried to set this up in Linux with MySQL 8.0.39 (not running in a container) and got the same result.

Am I doing something wrong? Any help would be greatly appreciated!

$ observable-database-proxy start localdb3
Database proxy localdb3 (mysql) running at http://127.0.0.1:2899
(node:22847) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version.
node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: self-signed certificate in certificate chain
    at TLSSocket.onConnectSecure (node:_tls_wrap:1679:34)
    at TLSSocket.emit (node:events:519:28)
    at TLSSocket._finishInit (node:_tls_wrap:1078:8)
    at ssl.onhandshakedone (node:_tls_wrap:864:12)
Emitted 'error' event on Connection instance at:
    at Connection._notifyError (/opt/homebrew/lib/node_modules/@observablehq/database-proxy/node_modules/mysql2/lib/connection.js:252:12)
    at ClientHandshake.<anonymous> (/opt/homebrew/lib/node_modules/@observablehq/database-proxy/node_modules/mysql2/lib/connection.js:141:14)
    at ClientHandshake.emit (node:events:531:35)
    at /opt/homebrew/lib/node_modules/@observablehq/database-proxy/node_modules/mysql2/lib/commands/client_handshake.js:155:16
    at TLSSocket.<anonymous> (/opt/homebrew/lib/node_modules/@observablehq/database-proxy/node_modules/mysql2/lib/connection.js:391:9)
    at TLSSocket.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  code: 'HANDSHAKE_SSL_ERROR',
  fatal: true
}

Node.js v22.9.0

This appears to be a bug in the proxy. The implementation references config.sslMode: "DISABLED" with a link to the JDBC connector docs while the proxy actually uses the mysql2 package. The package neither exposes a property sslMode nor handles an SSL profile “DISABLED”.

I think for now your only option might be to set NODE_TLS_REJECT_UNAUTHORIZED=0 when launching the proxy.