-
Notifications
You must be signed in to change notification settings - Fork 117
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
Fix bundle/stylesheet preload for AF-to-LW crossposts #9270
Conversation
When we start loading a post page, before we start rendering it in an SSR, we sometimes send the part of the header that tells the client to start downloading the stylesheet and javascript bundle. Before we can send that, we need to be sure the request is going to result in an http 200 (ie, not a 404 or a redirect). This is handled by `PostsRepo.postRouteWillDefinitelyReturn200`. However, this handled the AF flag incorrectly; rather than checking whether the user is loading a non-AF post on AF (which would trigger a redirect), it checks whether the user is loading an AF post (which can happen on either LW or AF, and will not trigger a redirect). This meant that AF posts didn't get the bundle/stylesheet preload, making them slower.
@@ -63,14 +63,16 @@ class PostsRepo extends AbstractRepo<"Posts"> { | |||
} | |||
|
|||
async postRouteWillDefinitelyReturn200(id: string): Promise<boolean> { | |||
const maybeRequireAF = isAF ? "AND af=true" : "" |
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.
Might be a pre-existing issue, but should this be af IS TRUE
?
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.
AFAIK these are equivalent (I tried select count(*) from "Posts" where af=true
and the same with is true
just now, and got the same result). We do seem to be favoring IS TRUE as a convention, though, so I'll change it for consistency's sake.
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 difference is that SELECT NULL IS TRUE
returns FALSE
, but SELECT NULL = TRUE
returns NULL
.
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.
No objections from EAF
When we start loading a post page, before we start rendering it in an SSR, we sometimes send the part of the header that tells the client to start downloading the stylesheet and javascript bundle. Before we can send that, we need to be sure the request is going to result in an http 200 (ie, not a 404 or a redirect). This is handled by
PostsRepo.postRouteWillDefinitelyReturn200
. However, this handled the AF flag incorrectly; rather than checking whether the user is loading a non-AF post on AF (which would trigger a redirect), it checks whether the user is loading an AF post (which can happen on either LW or AF, and will not trigger a redirect). This meant that AF posts didn't get the bundle/stylesheet preload, making them slower.┆Issue is synchronized with this Asana task by Unito