Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Node's "dns" module #288

Closed
bagusprabangkoro opened this issue Jul 6, 2022 · 13 comments
Closed

Implement Node's "dns" module #288

bagusprabangkoro opened this issue Jul 6, 2022 · 13 comments
Labels
node.js Compatibility with Node.js APIs

Comments

@bagusprabangkoro
Copy link

bagusprabangkoro commented Jul 6, 2022

Apparently, dns module is not included on bun runtime. I got this issue when trying to use PostgreSQL (pg) package.

pg version: ^8.7.3

Error message:

error: Could not resolve: "dns". Maybe you need to "bun install"?

var dns = require('dns')

Script that I'm trying to run:

const { Pool } = require('pg')

const pool = new Pool({
    user: 'test',
    database: 'test'
})

const run = async () => {
    const response = await DB.query('SELECT * FROM test LIMIT 10')
    console.log(response.rows)
}

run()
@Jarred-Sumner Jarred-Sumner changed the title Could not resolve "dns" module Implement Node's "dns" module Jul 7, 2022
@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented Jul 7, 2022

Node's dns module hasn't been implemented yet. Updating this issue to track that

@dylang
Copy link
Contributor

dylang commented Jul 11, 2022

DX suggestion: Instead of Could not resolve: "dns". Maybe you need to "bun install"? could the error message for non-implemented node features be something like:

Bun has not yet implemented node's dns package. You will need to disable code that uses this for now. Follow #288 for progress on this feature.

@mve
Copy link

mve commented Jul 12, 2022

Same thing for mongodb:

error: Could not resolve: "dns". Maybe you need to "bun install"?

const dns = require("dns");
                    ^
.../node_modules/mongodb/lib/connection_string.js:4:21 249%

@112RG
Copy link

112RG commented Jul 12, 2022

This is happening because bun is yet to implement that part of the Node.JS API. This is not because you need to install them. These are modules supplied by NodeJS itself like the FS module. You can see here https://github.com/oven-sh/bun/tree/main/src/bun.js/node the current modules of Node.JS that Bun supports

@github-actions github-actions bot removed the node label Jul 15, 2022
@sondreb
Copy link

sondreb commented Jul 16, 2022

Mongoose requires DNS as well, so unable to use MongoDB from Bun. I don't know if there are other options to communicate with MongoDB from Bun?

@erfanium
Copy link

@sondreb https://github.com/erfanium/atlas_sdk should work if you are using Atlas

@xHyroM xHyroM added node.js Compatibility with Node.js APIs polyfill labels Jul 28, 2022
@SheetJSDev
Copy link
Contributor

PR 929 implements a DoH fallback against cloudflare.

Note that after the patch, modules are still blocked by other issues like tls / net#Socket / RegExp lookbehind.

@spiffytech
Copy link

For informational purposes: the pg Postgres module is blocked by this.

@TechFun4
Copy link

TechFun4 commented Dec 9, 2022

this issue still persists with v0.3.0

@spiffytech
Copy link

Jarred has shown interest in implementing this for v0.4.0, as it's required for Vite support.

@Electroid Electroid removed the polyfill label Jan 6, 2023
@Jarred-Sumner
Copy link
Collaborator

A simple version of dns.lookup and dns.resolve is now available in the canary build of Bun - #1691

bun upgrade --canary

The issue for tracking the implementation progress of node:dns is here: #1744

@ThatOneCalculator
Copy link
Contributor

Does this now mean we'll get Vite support? 👀

@ThatOneBro
Copy link
Contributor

Does this now mean we'll get Vite support? 👀

Almost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests