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

add node:dns constants #3171

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ wd_ts_bundle(
"*.ts",
"*.js",
"assert/*.ts",
"dns/*.ts",
"stream/*.js",
"path/*.ts",
"util/*.ts",
Expand Down
5 changes: 5 additions & 0 deletions src/node/dns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { default as dnsUtil } from 'node-internal:dns';
import * as errorCodes from 'node-internal:internal_dns_constants';

export * from 'node-internal:internal_dns_constants';

export const getServers = dnsUtil.getServers.bind(dnsUtil);
export const lookup = dnsUtil.lookup.bind(dnsUtil);
Expand Down Expand Up @@ -44,4 +47,6 @@ export default {
setDefaultResultOrder,
getDefaultResultOrder,
setServers,

...errorCodes,
};
7 changes: 7 additions & 0 deletions src/node/dns/promises.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as errorCodes from 'node-internal:internal_dns_constants';

export * from 'node-internal:internal_dns_constants';

export default {
...errorCodes,
};
24 changes: 24 additions & 0 deletions src/node/internal/internal_dns_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const NODATA = 'ENODATA';
export const FORMERR = 'EFORMERR';
export const SERVFAIL = 'ESERVFAIL';
export const NOTFOUND = 'ENOTFOUND';
export const NOTIMP = 'ENOTIMP';
export const REFUSED = 'EREFUSED';
export const BADQUERY = 'EBADQUERY';
export const BADNAME = 'EBADNAME';
export const BADFAMILY = 'EBADFAMILY';
export const BADRESP = 'EBADRESP';
export const CONNREFUSED = 'ECONNREFUSED';
export const TIMEOUT = 'ETIMEOUT';
export const EOF = 'EOF';
export const FILE = 'EFILE';
export const NOMEM = 'ENOMEM';
export const DESTRUCTION = 'EDESTRUCTION';
export const BADSTR = 'EBADSTR';
export const BADFLAGS = 'EBADFLAGS';
export const NONAME = 'ENONAME';
export const BADHINTS = 'EBADHINTS';
export const NOTINITIALIZED = 'ENOTINITIALIZED';
export const LOADIPHLPAPI = 'ELOADIPHLPAPI';
export const ADDRGETNETWORKPARAMS = 'EADDRGETNETWORKPARAMS';
export const CANCELLED = 'ECANCELLED';
1 change: 1 addition & 0 deletions src/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"paths": {
"node:*": ["./*"],
"node:assert/*": ["./*"],
"node:dns/*": ["./*"],
"node:util/*": ["./*"],
"node:path/*": ["./*"],
"node:stream/*": ["./*"],
Expand Down
8 changes: 8 additions & 0 deletions src/workerd/api/node/tests/dns-nodejs-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dns from 'node:dns';
import dnsPromises from 'node:dns/promises';
import { strictEqual } from 'node:assert';

export const functionsExist = {
Expand Down Expand Up @@ -29,3 +30,10 @@ export const functionsExist = {
}
},
};

export const errorCodesExist = {
async test() {
strictEqual(typeof dns.NODATA, 'string');
strictEqual(typeof dnsPromises.NODATA, 'string');
},
};