-
Notifications
You must be signed in to change notification settings - Fork 432
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
Don't validate known lexicons at runtime #1790
Conversation
I'm 100% on board with this |
I very much support something to this effect 👍 I'm actually curious if it makes sense to remove the check all together? I think this made it in when we thought lexicons might be getting loaded into the client much more dynamically. But the way things stand, you know all lexicons at build time. It may make sense down the line to allow dynamically adding a lexicon which would require a parsing check We actually run these same typechecks on the lexicon documents during codegen, before they even have the chance to get build into the client. So it's not really serving us in DEV either |
What if the atproto/packages/api/src/client/lexicons.ts Line 7558 in 8637c36
|
Pushed changes:
Hope this works! |
This comment was marked as resolved.
This comment was marked as resolved.
6ad0d0d
to
4b3ebbf
Compare
@@ -415,16 +415,9 @@ export function isDiscriminatedObject( | |||
return discriminatedObject.safeParse(value).success | |||
} | |||
|
|||
export class LexiconDocMalformedError extends 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.
Technically removing this would necessitate going to 0.3.0 on the off-chance that someone imports it. Not sure if we care about this at this point. Happy to re-add.
4b3ebbf
to
399a1fd
Compare
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.
biiigg yup 👍
thanks for pushing on this!
❤️ |
* Make lexicon validation DEV-only * Apply code review suggestions
Here's what I'm seeing in the app's module initialization sequence with CPU throttling on:
It looks like we're spending client's CPU cycles validating that our own schemas are valid. I'm not sure it makes sense for a client to do that in production. From what I understand, these schemas are known at the build time, there's no way for them to have changed by any other way than deploying our code. So if they were valid when the app was built, it seems unnecessary to check whether they're valid on every end user's computer.
Without these lines, the init time shrinks considerably: