surrealdb / surrealdb.wasm

A WebAssembly engine for the SurrealDB JavaScript SDK
https://surrealdb.com
Apache License 2.0
118 stars 19 forks source link

Bug: Instantiating Surreal causes "node:crypto" error #54

Open var-che opened 9 months ago

var-che commented 9 months ago

Describe the bug

Instantiating Surreal wasm within the Reactjs part of the Nextjs project causes an error:

Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).

Steps to reproduce

Create a NextJs app and instantiate the Surreal database within the page.tsx.

"use client"
import {Surreal} from 'surrealdb.wasm';
export default function NameDoesntMatter() {
  prepareSurreal();
  return(<p>demo</p>);
}

async function prepareSurreal() {
  let db  = new Surreal();
  try {
    await db.connect('memory');
    await db.use({database: "db", namespace: "ns"});
  } catch (error) {
    console.log(error)
  }
}

Expected behaviour

I expect it to instantiate the database so that I can use in-memory one, on the browser.

I expect to be able to create a new user and query that user back.

SurrealDB version

surrealdb wasm 0.8.0 ubuntu 22.04.3 LST

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

dodikuswono commented 7 months ago

any workarround for this problem ?