web5-js icon indicating copy to clipboard operation
web5-js copied to clipboard

Web5.connect exits early when running project with node runtime

Open pmuens opened this issue 5 months ago • 1 comments

I've been following the Quickstart Guide on the TBD developer website and am running into an issue during step "1. Instantiate Web5 and Create DID" where I try to console.log the DID I just created.

Rather than logging the DID, the node runtime exists early. If I use bun on the other hand, everything is working fine and I can see my DID on the terminal. The interesting part is that once I ran bun index.js I can switch back to node index.js to see the same result I saw after running bun index.js.

Not sure if this could be a race condition or has something to do with node itself.

I'm running @web5/api version 0.8.4. My Node.js version is 20.5.1 and my Bun version is 2.0.14.

Here are the files I created:

// index.js
import { Web5 } from "@web5/api";

async function main() {
  const { web5, did: aliceDid } = await Web5.connect();

  console.log(aliceDid);
}

main();
// package.json
{
  "name": "web5-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@web5/api": "^0.8.4"
  },
  "type": "module"
}

Running node index.js returns early without logging anything. Running bun index.js logs the DID.

pmuens avatar Jan 31 '24 08:01 pmuens

FWIW: I can reproduce this on node 20.4.0, 20.5.0, 20.5.1, but not on 20.3.0 or before, or 20.6.0 or after. I recommend using the latest LTM release 20.11

ianpatton avatar Feb 12 '24 17:02 ianpatton