Skip to content

Commit b16903b

Browse files
committed
fix build
1 parent c8c64e7 commit b16903b

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

packages/functions/src/index.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ import { registerFunctions } from './config';
1919
export * from './api';
2020

2121
// eslint-disable-next-line @typescript-eslint/no-explicit-any
22-
registerFunctions('node');
22+
registerFunctions(fetch, 'node');

packages/functions/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ import { registerFunctions } from './config';
2525
export * from './api';
2626
export * from './public-types';
2727

28-
registerFunctions();
28+
registerFunctions(fetch.bind(self));

packages/functions/src/service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export class FunctionsService implements _FirebaseService {
104104
authProvider: Provider<FirebaseAuthInternalName>,
105105
messagingProvider: Provider<MessagingInternalComponentName>,
106106
appCheckProvider: Provider<AppCheckInternalComponentName>,
107-
regionOrCustomDomain: string = DEFAULT_REGION
107+
regionOrCustomDomain: string = DEFAULT_REGION,
108+
readonly fetchImpl: typeof fetch
108109
) {
109110
this.contextProvider = new ContextProvider(
110111
authProvider,
@@ -211,13 +212,14 @@ export function httpsCallableFromURL<RequestData, ResponseData>(
211212
async function postJSON(
212213
url: string,
213214
body: unknown,
214-
headers: { [key: string]: string }
215+
headers: { [key: string]: string },
216+
fetchImpl: typeof fetch
215217
): Promise<HttpResponse> {
216218
headers['Content-Type'] = 'application/json';
217219

218220
let response: Response;
219221
try {
220-
response = await fetch(url, {
222+
response = await fetchImpl(url, {
221223
method: 'POST',
222224
body: JSON.stringify(body),
223225
headers
@@ -294,7 +296,7 @@ async function callAtURL(
294296

295297
const failAfterHandle = failAfter(timeout);
296298
const response = await Promise.race([
297-
postJSON(url, body, headers),
299+
postJSON(url, body, headers, functionsInstance.fetchImpl),
298300
failAfterHandle.promise,
299301
functionsInstance.cancelAllRequests
300302
]);

packages/functions/test/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export function createTestService(
6262
authProvider,
6363
messagingProvider,
6464
appCheckProvider,
65-
region
65+
region,
66+
fetch
6667
);
6768
const useEmulator = !!process.env.FIREBASE_FUNCTIONS_EMULATOR_ORIGIN;
6869
if (useEmulator) {

0 commit comments

Comments
 (0)