From 0ff1d88d25c5f3e505010a3f403fd454729b9628 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Mon, 17 Nov 2025 16:55:44 -0500 Subject: [PATCH 1/3] feat(NODE-7302): remove dependency on uri.parse() --- src/utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 9307714d90..16079a8adf 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -4,8 +4,6 @@ import { type EventEmitter } from 'events'; import { promises as fs } from 'fs'; import * as http from 'http'; import { clearTimeout, setTimeout } from 'timers'; -import * as url from 'url'; -import { URL } from 'url'; import { promisify } from 'util'; import { deserialize, type Document, ObjectId, resolveBSONOptions } from './bson'; @@ -1218,7 +1216,7 @@ export async function request( method: 'GET', timeout: 10000, json: true, - ...url.parse(uri), + url: new URL(uri), ...options }; From 5223a7c2c972150780ea0815cbec3f7bf7d328da Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 18 Nov 2025 09:53:13 -0500 Subject: [PATCH 2/3] refactor: remove dead code --- src/utils.ts | 58 ---------------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 16079a8adf..786557c6c4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1198,64 +1198,6 @@ export function get( }); } -export async function request(uri: string): Promise>; -export async function request( - uri: string, - options?: { json?: true } & RequestOptions -): Promise>; -export async function request( - uri: string, - options?: { json: false } & RequestOptions -): Promise; -export async function request( - uri: string, - options: RequestOptions = {} -): Promise> { - return await new Promise>((resolve, reject) => { - const requestOptions = { - method: 'GET', - timeout: 10000, - json: true, - url: new URL(uri), - ...options - }; - - const req = http.request(requestOptions, res => { - res.setEncoding('utf8'); - - let data = ''; - res.on('data', d => { - data += d; - }); - - res.once('end', () => { - if (options.json === false) { - resolve(data); - return; - } - - try { - const parsed = JSON.parse(data); - resolve(parsed); - } catch { - // TODO(NODE-3483) - reject(new MongoRuntimeError(`Invalid JSON response: "${data}"`)); - } - }); - }); - - req.once('timeout', () => - req.destroy( - new MongoNetworkTimeoutError( - `Network request to ${uri} timed out after ${options.timeout} ms` - ) - ) - ); - req.once('error', error => reject(error)); - req.end(); - }); -} - /** @internal */ export const DOCUMENT_DB_CHECK = /(\.docdb\.amazonaws\.com$)|(\.docdb-elastic\.amazonaws\.com$)/; /** @internal */ From db4708b05acbef8106bd4f3a5f09f58a5f5fbf81 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 18 Nov 2025 10:32:45 -0500 Subject: [PATCH 3/3] refactor: remove request options --- src/utils.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 786557c6c4..e078f91d7c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1159,13 +1159,6 @@ export function checkParentDomainMatch(address: string, srvHost: string): void { } } -interface RequestOptions { - json?: boolean; - method?: string; - timeout?: number; - headers?: http.OutgoingHttpHeaders; -} - /** * Perform a get request that returns status and body. * @internal