surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
272 stars 45 forks source link

Bug: node_js_1.default is not a constructor at SurrealSocket.open #224

Closed bawas closed 3 weeks ago

bawas commented 3 months ago

Describe the bug

try to connect with websocket inside a serverless framework lambda with nodejs.16x as runtime

error: TypeError: node_js_1.default is not a constructor
      at SurrealSocket.open (/var/task/node_modules/surrealdb.js/script/library/SurrealSocket.js:92:20)

i found a issue similar to this, but i dont have the dependencies which apparently was generating the error. Before i was using the SurrealDB.js with version 0.5.0 and it was working fine

Steps to reproduce

import { Surreal } from 'surrealdb.js';

const db = new Surreal();

// this line throws an error
await surrealDb.connect(process.env.SURREAL_URL, {
      auth: {
        username: process.env.SURREAL_USERNAME,
        password: process.env.SURREAL_PASSWORD,
      },
      namespace: process.env.SURREAL_NAMESPACE,
      database: process.env.SURREAL_DBNAME,
    });

Expected behaviour

The connection should initialize and not throw an error

SurrealDB version

v1.2.1

SurrealDB.js version

0.11.0

Contact Details

tharris@cloudcar.cl

Is there an existing issue for this?

Code of Conduct

macjuul commented 3 months ago

I can't reproduce this issue myself when running surrealdb.js directly in node.js 16

kearfy commented 3 weeks ago

Closing as stale, please let me know if this issue still occurs on the 1.0.0 beta versions of the library