Skip to content

Commit e8b41f6

Browse files
authored
Add regression test for previously hanging compilation with Turbopack (#75507)
When adding or removing a `"use cache"` directive to a function or module, Turbopack was not able to finish the compilation and hung. This is now fixed, and we're adding the test to prevent regression.
1 parent 7498199 commit e8b41f6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/development/app-dir/use-cache-hmr/use-cache-hmr.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,29 @@ describe('use-cache-hmr', () => {
101101
})
102102
)
103103
})
104+
105+
it('should successfully finish compilation when "use cache" directive is added/removed', async () => {
106+
await next.browser('/')
107+
let cliOutputLength = next.cliOutput.length
108+
109+
// Disable "use cache" directive
110+
await next.patchFile('app/page.tsx', (content) =>
111+
content.replace(`'use cache'`, `// 'use cache'`)
112+
)
113+
114+
await retry(async () => {
115+
expect(next.cliOutput.slice(cliOutputLength)).toInclude('✓ Compiled')
116+
}, 10_000)
117+
118+
cliOutputLength = next.cliOutput.length
119+
120+
// Re-enable "use cache" directive
121+
await next.patchFile('app/page.tsx', (content) =>
122+
content.replace(`// 'use cache'`, `'use cache'`)
123+
)
124+
125+
await retry(async () => {
126+
expect(next.cliOutput.slice(cliOutputLength)).toInclude('✓ Compiled')
127+
}, 10_000)
128+
})
104129
})

0 commit comments

Comments
 (0)