diff --git a/packages/api/src/features/applications/ai.test.ts b/packages/api/src/features/applications/ai.test.ts
index 2eee5628d..9b294217a 100644
--- a/packages/api/src/features/applications/ai.test.ts
+++ b/packages/api/src/features/applications/ai.test.ts
@@ -104,6 +104,27 @@ describe("fetchJobPostingText", () => {
await expect(fetchJobPostingText("https://jobs.example/posting")).resolves.toBe("Senior Engineer");
expect(pinnedAddress).toBe("93.184.216.34");
});
+
+ it("supports Node lookup calls with all=true", async () => {
+ lookupMock.mockResolvedValue([{ address: "93.184.216.34", family: 4 }]);
+ let lookupResult: unknown;
+ requestMock.mockImplementation((_url, options, callback) => {
+ options.lookup("jobs.example", { all: true }, (_error: Error | null, result: unknown) => {
+ lookupResult = result;
+ });
+ const response = Readable.from([Buffer.from("
Senior Engineer")]) as Readable & {
+ statusCode: number;
+ headers: Record;
+ };
+ response.statusCode = 200;
+ response.headers = { "content-type": "text/html" };
+ callback(response);
+ return { on: vi.fn(), end: vi.fn() };
+ });
+
+ await expect(fetchJobPostingText("https://jobs.example/posting")).resolves.toBe("Senior Engineer");
+ expect(lookupResult).toEqual([{ address: "93.184.216.34", family: 4 }]);
+ });
});
describe("autofillInputSchema", () => {
diff --git a/packages/api/src/features/applications/ai.ts b/packages/api/src/features/applications/ai.ts
index 89b23fd27..156a9b93c 100644
--- a/packages/api/src/features/applications/ai.ts
+++ b/packages/api/src/features/applications/ai.ts
@@ -163,7 +163,14 @@ function requestJobPosting(parsed: URL, address: ValidatedAddress, signal: Abort
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"accept-language": "en-US,en;q=0.9",
},
- lookup: (_hostname, _options, callback) => callback(null, address.address, address.family),
+ lookup: (_hostname, options, callback) => {
+ if (options.all) {
+ callback(null, [address]);
+ return;
+ }
+
+ callback(null, address.address, address.family);
+ },
},
resolve,
);