Skip to content

Commit

Permalink
DNS fixes (oven-sh#15864)
Browse files Browse the repository at this point in the history
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
  • Loading branch information
heimskr and Jarred-Sumner authored Jan 9, 2025
1 parent 2465cca commit 9bca80c
Show file tree
Hide file tree
Showing 45 changed files with 3,804 additions and 638 deletions.
4 changes: 4 additions & 0 deletions packages/bun-types/bun.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@ declare module "bun" {
errors: number;
totalCount: number;
};

ADDRCONFIG: number;
ALL: number;
V4MAPPED: number;
};

interface DNSLookup {
Expand Down
9 changes: 8 additions & 1 deletion scripts/runner.node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ const spawnTimeout = 5_000;
const testTimeout = 3 * 60_000;
const integrationTimeout = 5 * 60_000;

function getNodeParallelTestTimeout(testPath) {
if (testPath.includes("test-dns")) {
return 90_000;
}
return 10_000;
}

const { values: options, positionals: filters } = parseArgs({
allowPositionals: true,
options: {
Expand Down Expand Up @@ -251,7 +258,7 @@ async function runTests() {
const { ok, error, stdout } = await spawnBun(execPath, {
cwd: cwd,
args: [title],
timeout: 10_000,
timeout: getNodeParallelTestTimeout(title),
env: {
FORCE_COLOR: "0",
},
Expand Down
9 changes: 9 additions & 0 deletions src/bun.js/api/Timer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Async = @import("async");
const uv = bun.windows.libuv;
const StatWatcherScheduler = @import("../node/node_fs_stat_watcher.zig").StatWatcherScheduler;
const Timer = @This();
const DNSResolver = @import("./bun/dns_resolver.zig").DNSResolver;

/// TimeoutMap is map of i32 to nullable Timeout structs
/// i32 is exposed to JavaScript and can be used with clearTimeout, clearInterval, etc.
Expand Down Expand Up @@ -730,6 +731,7 @@ pub const EventLoopTimer = struct {
TestRunner,
StatWatcherScheduler,
UpgradedDuplex,
DNSResolver,
WindowsNamedPipe,
PostgresSQLConnectionTimeout,
PostgresSQLConnectionMaxLifetime,
Expand All @@ -741,6 +743,7 @@ pub const EventLoopTimer = struct {
.TestRunner => JSC.Jest.TestRunner,
.StatWatcherScheduler => StatWatcherScheduler,
.UpgradedDuplex => uws.UpgradedDuplex,
.DNSResolver => DNSResolver,
.WindowsNamedPipe => uws.WindowsNamedPipe,
.PostgresSQLConnectionTimeout => JSC.Postgres.PostgresSQLConnection,
.PostgresSQLConnectionMaxLifetime => JSC.Postgres.PostgresSQLConnection,
Expand All @@ -752,6 +755,7 @@ pub const EventLoopTimer = struct {
TestRunner,
StatWatcherScheduler,
UpgradedDuplex,
DNSResolver,
PostgresSQLConnectionTimeout,
PostgresSQLConnectionMaxLifetime,

Expand All @@ -762,6 +766,7 @@ pub const EventLoopTimer = struct {
.TestRunner => JSC.Jest.TestRunner,
.StatWatcherScheduler => StatWatcherScheduler,
.UpgradedDuplex => uws.UpgradedDuplex,
.DNSResolver => DNSResolver,
.PostgresSQLConnectionTimeout => JSC.Postgres.PostgresSQLConnection,
.PostgresSQLConnectionMaxLifetime => JSC.Postgres.PostgresSQLConnection,
};
Expand Down Expand Up @@ -841,6 +846,10 @@ pub const EventLoopTimer = struct {
return .disarm;
}

if (comptime t.Type() == DNSResolver) {
return container.checkTimeouts(now, vm);
}

return container.callback(container);
},
}
Expand Down
Loading

0 comments on commit 9bca80c

Please sign in to comment.