Skip to content

Commit d5475b2

Browse files
committed
fix(undiciRequest): file uploading
1 parent 02fc101 commit d5475b2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/rest/src/strategies/undiciRequest.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { STATUS_CODES } from 'node:http';
22
import { URLSearchParams } from 'node:url';
33
import { types } from 'node:util';
4-
import { type RequestInit, request, Headers, FormData as UndiciFormData } from 'undici';
4+
import { type RequestInit, request, Headers, FormData as UndiciFormData, Agent } from 'undici';
55
import type { HeaderRecord } from 'undici/types/header.js';
66
import type { ResponseLike } from '../shared.js';
77

@@ -14,6 +14,11 @@ export async function makeRequest(url: string, init: RequestInit): Promise<Respo
1414
...init,
1515
body: await resolveBody(init.body),
1616
} as RequestOptions;
17+
18+
// Not setting a dispatcher makes requests fail whenever files are involved. So we set a default one.
19+
// https://github.com/nodejs/node/issues/59012
20+
options.dispatcher ??= new Agent();
21+
1722
const res = await request(url, options);
1823
return {
1924
body: res.body,

0 commit comments

Comments
 (0)