Why am I getting "Unknown encoding: <ref *1> Handshake" when I try to use NodeJS and MariaDB?

Viewed 1203

I have the following NodeJs code...

import mariadb from "mariadb";

class MariaConnector{
    constructor(
        password = process.env.SQL_PASSWORD,
        host="192.168.1.193",
        user="API",
        database = "SITE"){
        this.host = host;
        this.password = password;
        this.user = user;
        this.database = database;
        this.connectionLimit = 5;
    }
    get connection(){
        console.log(`The password is ${this.password}`)
        // return this.pool.getConnection();
        return mariadb.createConnection(this)
    }
}

When I try to run the program and it calls get connection, the password prints out fine but I get...

_stream_writable.js:296
      throw new ERR_UNKNOWN_ENCODING(encoding);
      ^

TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: <ref *1> Handshake {
  _events: [Object: null prototype],
  _eventsCount: 1,

I would expect it to work since this exact same config is what I use in my Desktop SQL client that works fine.

1 Answers

Updating the mariadb module to the latest version (2.5.2) worked for me. You could use yarn upgrade or npm update for that.

Related