-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
20a53a1
eviction
lukesandberg b4a8ace
fix cell eviction
lukesandberg 3b028be
run eviction in integration tests
lukesandberg 87bf84c
drop it likes it hot
lukesandberg 99576ca
review feedback
lukesandberg daa7c5c
fix persistence enum
lukesandberg 27f43c2
fix transient residue destroyed by drop_partial
lukesandberg 4167939
fix clippy
lukesandberg ebda946
don't run background snapshots in our test harness
lukesandberg 8ff438a
but for all integration tests
lukesandberg fd1ba33
fix merge
lukesandberg ecae0e6
simplify settings again
lukesandberg b9114df
review fixes
lukesandberg 5340462
fix restoration for persistable but not evictable data
lukesandberg 8237c60
simplify
lukesandberg abf2b68
customize trait for restoration
lukesandberg 659b6b6
fix a deadlock when updating state
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
| 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.