stackblitz/webcontainer-docs

Native node backend capabilities

Opened this issue · 2 comments

Describe the bug
Hello, I am trying testing mongoDB connection from a webcontainer. But i was unable to get it working. After debugging I saw it gets stuck in dns.promises.resolveSrv call. It does not get resolved nor gets rejected. I checked the documentation and nothing mentions about native node limitations. So, I wonder if this is a bug or are there limitations.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://webcontainers.io/
  2. Click on 'index.js' editor portion of the page.
  3. paste the following script.
import dns from "dns";

dns.promises.resolveSrv('_mongodb._tcp.cluster0.cb93mrj.mongodb.net').then(() => console.log('then')).catch(() => console.log('catch'));

console.log(`Hello Node.js v${process.versions.node}!`);
setTimeout(() => console.log('time is up :('), 5000);
  1. Click on "Run index.js" or type "node index.js" in the terminal portion of the screen and press enter.
  2. See "Hello Node.js v16.14.2!" and "time is up :(" lines. But there is no catch neither then. Promise just gets vaporised.

Expected behavior
dns.promises.resolveSrv call returns a promise which should be either resolved or rejected.

Screenshots
image

Desktop (please complete the following information):

  • OS: MacOS Ventura 13.3.1 (a)
  • Browser: Microsoft Edge
  • Version: Version 113.0.1774.35 (Official build) (arm64)

It seems the DNS layer is not working in native node webcontainer

@alper-batioglu
refer to this answer of webcontainer maintainer
stackblitz/webcontainer-core#1106 (comment)

we don't support databases like Mongo out of the box, b/c that would require something akin to low-level networking in the browser (e.g. TCP/UDP sockets, DNS, etc.), which don't currently exist. We are thinking about ways around this, but we don't have any concrete roadmap about it. If you're interested, we can leave this open as a venue for updates in case anything changes.