-
Notifications
You must be signed in to change notification settings - Fork 31k
Proof of concept: task eviction after snapshot for turbo-tasks-backend #91790
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
Open
lukesandberg
wants to merge
8
commits into
canary
Choose a base branch
from
eviction_semantics_for_real_this_time
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
998feaa
fix a snapshot encoding error that could happen under concurrent muta…
lukesandberg 16f0498
address comemnt
lukesandberg 6c9417c
eviction
lukesandberg a27e448
fix cell eviction
lukesandberg 38e75b4
run eviction in integration tests
lukesandberg 57f824c
drop it likes it hot
lukesandberg 8bca729
review feedback
lukesandberg 1e85dc1
fix persistence enum
lukesandberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import { nextTestSetup, isNextDev } from 'e2e-utils' | ||
| import { retry, waitFor } from 'next-test-utils' | ||
|
|
||
| // Eviction requires the dev server (HMR) and persistent caching (Turbopack). | ||
| // Skip entirely in prod/start mode. | ||
| ;(isNextDev ? describe : describe.skip)('evict-after-snapshot', () => { | ||
| const envVars = [ | ||
| 'ENABLE_CACHING=1', | ||
| 'TURBO_ENGINE_IGNORE_DIRTY=1', | ||
| 'TURBO_ENGINE_SNAPSHOT_IDLE_TIMEOUT_MILLIS=1000', | ||
| 'TURBO_ENGINE_EVICT_AFTER_SNAPSHOT=1', | ||
| ].join(' ') | ||
|
|
||
| const { skipped, next } = nextTestSetup({ | ||
| files: __dirname, | ||
| skipDeployment: true, | ||
| packageJson: { | ||
| scripts: { | ||
| dev: `${envVars} next dev`, | ||
| }, | ||
| }, | ||
| installCommand: 'npm i', | ||
| startCommand: 'npm run dev', | ||
| }) | ||
|
|
||
| if (skipped) { | ||
|
lukesandberg marked this conversation as resolved.
|
||
| return | ||
| } | ||
|
|
||
| async function waitForSnapshotAndEviction() { | ||
| // The idle timeout is 1s, give extra time for snapshot + eviction to complete | ||
| await waitFor(5000) | ||
| } | ||
|
|
||
| // Turbopack-only: eviction requires persistent caching | ||
| ;(process.env.IS_TURBOPACK_TEST ? it : it.skip)( | ||
| 'should serve correct content after eviction and HMR', | ||
| async () => { | ||
| const browser = await next.browser('/') | ||
| await retry(async () => { | ||
| expect(await browser.elementByCss('p').text()).toBe('hello world') | ||
| }) | ||
|
|
||
| let currentContent = 'hello world' | ||
| for (let cycle = 1; cycle <= 3; cycle++) { | ||
| await waitForSnapshotAndEviction() | ||
|
|
||
| const prevContent = currentContent | ||
| const nextContent = `cycle ${cycle}` | ||
| await next.patchFile('app/page.tsx', (content) => | ||
| content.replace(prevContent, nextContent) | ||
| ) | ||
| currentContent = nextContent | ||
|
|
||
| const expected = currentContent | ||
| await retry(async () => { | ||
| expect(await browser.elementByCss('p').text()).toBe(expected) | ||
| }, 10000) | ||
| } | ||
|
|
||
| await browser.close() | ||
| }, | ||
| 90000 | ||
| ) | ||
| ;(process.env.IS_TURBOPACK_TEST ? it : it.skip)( | ||
| 'should handle client component HMR after eviction', | ||
| async () => { | ||
| const browser = await next.browser('/client') | ||
| await retry(async () => { | ||
| expect(await browser.elementByCss('p').text()).toBe('hello world') | ||
| }) | ||
|
|
||
| await waitForSnapshotAndEviction() | ||
|
|
||
| await next.patchFile( | ||
| 'app/client/page.tsx', | ||
| (content) => content.replace('hello world', 'hello eviction'), | ||
| async () => { | ||
| await retry(async () => { | ||
| expect(await browser.elementByCss('p').text()).toBe( | ||
| 'hello eviction' | ||
| ) | ||
| }, 10000) | ||
| } | ||
| ) | ||
|
|
||
| await browser.close() | ||
| }, | ||
| 90000 | ||
| ) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.