Last active
June 29, 2020 16:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}, []); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from "firebase-functions"; | |
export const helloWorld = functions.https.onCall((data, context) => { | |
return { message: "Hello!" }; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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