Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This simple callable function throws a deadline-exceed error, even when it successfully returns a response.
import React, { useEffect } from "react";
// Run the callable function on mount only once by adding an empty array.
export function Callable() {
useEffect(() => {
async function helloWorld() {
try {
const helloWorldCallableFunction = functions.httpsCallable("helloWorld", { timeout: 10000 });
const response = await helloWorldCallableFunction();
console.log(response.data);
} catch (error) {
console.log(error);
}
}
helloWorld();
}, []);
}
import * as functions from "firebase-functions";
export const helloWorld = functions.https.onCall((data, context) => {
return { message: "Hello!" };
});
// This is the code in the firebase SDK that throws the error.
// Issue: https://github.com/firebase/firebase-js-sdk/issues/3289#issuecomment-650466360
function failAfter(millis: number): Promise<never> {
return new Promise((_, reject) => {
setTimeout(() => {
reject(new HttpsErrorImpl('deadline-exceeded', 'deadline-exceeded'));
}, millis);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment