chicago-brick icon indicating copy to clipboard operation
chicago-brick copied to clipboard

Guard authenticate_google_api's calls to OAuth

Open applmak opened this issue 1 year ago • 0 comments

Hi. I saw an error like this which stopped the execution of the wall server:

error: Uncaught TypeError: error sending request for url (https://oauth2.googleapis.com/token): error trying to connect: dns error: failed to lookup address information: Name or service not known
    const res = await fetch("https://oauth2.googleapis.com/token", {
                ^
    at async mainFetch (deno:ext/fetch/26_fetch.js:247:14)
    at async fetch (deno:ext/fetch/26_fetch.js:464:9)
    at async GoogleAuth.refreshToken (chicago-brick/server/util/authenticate_google_api.ts:73:17)
    at async GoogleAuth.getRequestHeaders (chicago-brick/server/util/authenticate_google_api.ts:29:7)
    at async driveFilesList (chicago-brick/demo_modules/slideshow/load_from_drive_server.ts:43:26)
    at async Object.start (chicago-brick/demo_modules/slideshow/load_from_drive_server.ts:84:28)

This should probably be guarded against via some kind of try/catch to at least prevent this kind of failure (also, maybe installing a top-level unhandled exception handler is a good approach, too)? I don't know why this would happen. Introducing some kind of retry-like functionality would be smart here, too, with an exponential backoff.

I suspect that this is causing regular issues with the wall.

applmak avatar Sep 11 '23 12:09 applmak