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: skew protection #1658

Merged
merged 8 commits into from
Oct 12, 2024
Merged

fix: skew protection #1658

merged 8 commits into from
Oct 12, 2024

Conversation

abvthecity
Copy link
Contributor

@abvthecity abvthecity commented Oct 11, 2024

Problem 1: when you run vercel build then vercel deploy --prebuilt, we don't actually get access to any of the vercel-specific environment variables, e.g. VERCEL_DEPLOYMENT_ID or VERCEL_ENV at built-time. So, we needed to switch the deployment model such that source files are uploaded to vercel so that vercel build the deployment directly.

Problem 2: nextjs (perhaps because we're using a fork of nextjs?) is not correctly setting the x-deployment-id header in the prefetch requests. to circumvent this, we're appending ?dpl=${process.env.NEXT_DEPLOYMENT_ID} to all prefetch requests from the router. This will force skew protection on prefetching!

Problem 3: all other fetch requests to /api/fern-docs/* must have the x-deployment-id header set to leverage skew protection. For some reason, nextjs is stripping away this header, so we are appending ?dpl= instead.

Side effect: nextjs bundle analyzer requires that the nextjs bundle is done locally. I've updated the gh action script to handle this.

Copy link

github-actions bot commented Oct 11, 2024

Playwright test results

passed  1 passed

Details

stats  1 test across 1 suite
duration  9.4 seconds
commit  58aa20a

Copy link

github-actions bot commented Oct 11, 2024

PR Preview

Copy link

github-actions bot commented Oct 11, 2024

📦 Next.js Bundle Analysis for fern-platform-monorepo

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 162.56 KB (🟢 -94.73 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

New Pages Added

The following pages were added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/404 332 B 162.88 KB 46.54%
/dynamic/[domain]/[[...slug]] 52.7 KB 215.26 KB 61.50%
/static/[domain]/[[...slug]] 52.7 KB 215.26 KB 61.50%

Copy link

github-actions bot commented Oct 11, 2024

Playwright test results

passed  81 passed

Details

stats  81 tests across 3 suites
duration  1 minute, 13 seconds
commit  58aa20a

@abvthecity abvthecity requested a review from dsinghvi as a code owner October 11, 2024 23:14
@abvthecity abvthecity had a problem deploying to Preview - app-dev.buildwithfern.com October 12, 2024 00:36 — with GitHub Actions Error
@abvthecity abvthecity had a problem deploying to Preview - app.buildwithfern.com October 12, 2024 00:36 — with GitHub Actions Error
@abvthecity abvthecity had a problem deploying to Preview - app-dev.buildwithfern.com October 12, 2024 00:44 — with GitHub Actions Error
@abvthecity abvthecity had a problem deploying to Preview - app.buildwithfern.com October 12, 2024 00:44 — with GitHub Actions Error
@abvthecity abvthecity merged commit 9b693b7 into main Oct 12, 2024
21 checks passed
@abvthecity abvthecity deleted the ajiang/skew-protection branch October 12, 2024 03:18
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.

2 participants