Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use v2 Firebase functions #113

Open
ky28059 opened this issue Jul 31, 2022 · 0 comments
Open

Use v2 Firebase functions #113

ky28059 opened this issue Jul 31, 2022 · 0 comments

Comments

@ky28059
Copy link
Member

ky28059 commented Jul 31, 2022

For docs on the public preview, see the firebase docs. Upgrading to v2 would allow for easier cors configuration, but more importantly it adds support for concurrency which might save a lot on cold start times; for API especially, I'm not sure keeping one instance always warm is enough to eliminate huge startup costs on multiple requests.

The issue for WATT is that we can't adopt the gradual upgrade strategy described in the docs where v1 and v2 functions exist in the same codebase because sgyAuth and sgyFetch rely on functions.config(), a method that is removed in v2 in favor of secrets and environment variables. Updating those functions to v2 would require moving .runtimeconfig.json to .env.local like

SGY_KEY=...
SGY_SECRET=...

and rewriting sgyOAuth to use process.env.SGY_KEY and process.env.SGY_SECRET (this might require making a new instance of oauth per request due to secrets being function-scoped). However, sgyAuth and sgyFetch are all callable functions and suffer from caveats while v2 functions are in beta that require changing

const init = httpsCallable(functions, 'sgyfetch-init');

to something like

const init = httpsCallableFromURL(functions, 'https://gunnwatt-uvb3o4q2mq-uw.a.run.app/sgyfetch-init');

and because v2 function URLs are non-deterministic this URL would need to be updated every time the function is changed and redeployed.

If cold starts end up becoming a huge deal, we might want to upgrade to v2 despite these limitations, but otherwise we can wait until cloudfunctions.net URLs are supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant