-
Notifications
You must be signed in to change notification settings - Fork 927
Add core types & error map to auth-exp #2890
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
Conversation
WEB_STORAGE_UNSUPPORTED = 'web-storage-unsupported' | ||
} | ||
|
||
const ERRORS: ErrorMap<AuthErrorCode> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll start the discussion here - is there a way we can make this optional? All these strings will be a large part of the compiled binary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, it might be good to have separate error maps for "dev" and "prod", that way the user could choose which gets included. That would require the AUTH_ERROR_FACTORY to not be a constant.
I think we can mull this for a while, but to make that change more straightforward in the future, maybe this module should export a function instead of a constant?
export function getErrorFactory() { return AUTH_ERROR_FACTORY }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interested in what others think about this... @bojeil-google ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assert model is cool, but doesn't work great in auth since most of our error messages are translations for server side errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this list also includes client side errors that do not map to server side errors.
So you are suggesting to make error mapping functionality modular? So if the developer does not import it, then what happens?
Expecting the developer to know what errors to include puts a lot of burden on the developer. They would need to understand each error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for production builds we could just have a short code that can be mapped in our documentation, something like Error: auth/email-exists, with the full description & troubleshooting tips available online
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be a breaking API change though, and we would need the page up on the documentation before we could launch this, but it would be cool and could potentially make the final binary that much smaller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I misunderstood your suggestion. You are suggesting modularization of the error messages population component and not the entire client side errors (and how they are mapped from server to client). That may not be terrible but a breaking change, alas.
I agree we should optimize this but I would suggest we think about it more (this also seems like a general problem and not specific to Auth). JsCore should try to find a unified solution for it. I would recommend implementing the current spec in its current form for now and then experimenting with the generated binary and revisiting this to see how we can avoid bundling these messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree on punting this to JS core for now, lets proceed as is, we can measure the possible effect of the strings during alpha and maybe implement this during beta
WEB_STORAGE_UNSUPPORTED = 'web-storage-unsupported' | ||
} | ||
|
||
const ERRORS: ErrorMap<AuthErrorCode> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, it might be good to have separate error maps for "dev" and "prod", that way the user could choose which gets included. That would require the AUTH_ERROR_FACTORY to not be a constant.
I think we can mull this for a while, but to make that change more straightforward in the future, maybe this module should export a function instead of a constant?
export function getErrorFactory() { return AUTH_ERROR_FACTORY }
we can make an implementation class later
LGTM |
* Add core types & error map * [AUTOMATED]: Prettier Code Styling * [AUTOMATED]: License Headers * User should be an interface for now we can make an implementation class later
* Add core types & error map * [AUTOMATED]: Prettier Code Styling * [AUTOMATED]: License Headers * User should be an interface for now we can make an implementation class later
* Add core types & error map * [AUTOMATED]: Prettier Code Styling * [AUTOMATED]: License Headers * User should be an interface for now we can make an implementation class later
Hey there! So you want to contribute to a Firebase SDK?
Before you file this pull request, please read these guidelines:
Discussion
If not, go file an issue about this before creating a pull request to discuss.
Testing
API Changes
us make Firebase APIs better, please propose your change in an issue so that we
can discuss it together.