Skip to content

Instantly share code, notes, and snippets.

@stevecastaneda
Last active June 29, 2020 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevecastaneda/7c07f91ce1eeef005175071efda39401 to your computer and use it in GitHub Desktop.
Save stevecastaneda/7c07f91ce1eeef005175071efda39401 to your computer and use it in GitHub Desktop.
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