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

Fix bundle/stylesheet preload for AF-to-LW crossposts #9270

Merged
merged 2 commits into from
May 16, 2024

Conversation

jimrandomh
Copy link
Collaborator

@jimrandomh jimrandomh commented May 12, 2024

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

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.
@jimrandomh jimrandomh requested a review from a team as a code owner May 12, 2024 06:47
@jimrandomh jimrandomh requested review from oetherington and removed request for a team May 12, 2024 06:47
@@ -63,14 +63,16 @@ class PostsRepo extends AbstractRepo<"Posts"> {
}

async postRouteWillDefinitelyReturn200(id: string): Promise<boolean> {
const maybeRequireAF = isAF ? "AND af=true" : ""
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@oetherington oetherington left a 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

@jimrandomh jimrandomh merged commit 978356f into master May 16, 2024
18 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants