Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
82dc672a
Unverified
Commit
82dc672a
authored
Mar 14, 2024
by
Dima Voytenko
Committed by
GitHub
Mar 14, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable cache in testmode (#63265)
Fixes #63127.
parent
6d45c325
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
index.ts
packages/next/src/server/lib/incremental-cache/index.ts
+7
-4
testmode.test.ts
test/e2e/testmode/testmode.test.ts
+12
-2
No files found.
packages/next/src/server/lib/incremental-cache/index.ts
View file @
82dc672a
...
...
@@ -66,6 +66,7 @@ export class CacheHandler {
export
class
IncrementalCache
implements
IncrementalCacheType
{
dev
?:
boolean
disableForTestmode
?:
boolean
cacheHandler
?:
CacheHandler
hasCustomCacheHandler
:
boolean
prerenderManifest
:
PrerenderManifest
...
...
@@ -142,6 +143,7 @@ export class IncrementalCache implements IncrementalCacheType {
maxMemoryCacheSize
=
parseInt
(
process
.
env
.
__NEXT_TEST_MAX_ISR_CACHE
,
10
)
}
this
.
dev
=
dev
this
.
disableForTestmode
=
process
.
env
.
NEXT_PRIVATE_TEST_PROXY
===
'true'
// this is a hack to avoid Webpack knowing this is equal to this.minimalMode
// because we replace this.minimalMode to true in production bundles.
const
minimalModeKey
=
'minimalMode'
...
...
@@ -441,9 +443,10 @@ export class IncrementalCache implements IncrementalCacheType {
// we don't leverage the prerender cache in dev mode
// so that getStaticProps is always called for easier debugging
if (
this.dev &&
(ctx.kindHint !== 'fetch' ||
this.requestHeaders['cache-control'] === 'no-cache')
this.disableForTestmode ||
(this.dev &&
(ctx.kindHint !== 'fetch' ||
this.requestHeaders['cache-control'] === 'no-cache'))
) {
return null
}
...
...
@@ -560,7 +563,7 @@ export class IncrementalCache implements IncrementalCacheType {
})
}
if (this.d
ev && !ctx.fetchCache
) return
if (this.d
isableForTestmode || (this.dev && !ctx.fetchCache)
) return
// FetchCache has upper limit of 2MB per-entry currently
const itemSize = JSON.stringify(data).length
if (
...
...
test/e2e/testmode/testmode.test.ts
View file @
82dc672a
...
...
@@ -38,11 +38,11 @@ createNextDescribe(
proxyServer
.
close
()
})
const
fetchForTest
=
async
(
url
:
string
)
=>
{
const
fetchForTest
=
async
(
url
:
string
,
testData
?:
string
)
=>
{
return
next
.
fetch
(
url
,
{
headers
:
{
'Next-Test-Proxy-Port'
:
String
(
proxyServer
.
port
),
'Next-Test-Data'
:
'test1'
,
'Next-Test-Data'
:
testData
??
'test1'
,
},
})
}
...
...
@@ -53,6 +53,16 @@ createNextDescribe(
expect
(
html
).
toContain
(
'<pre>test1</pre>'
)
})
it
(
'should avoid fetch cache'
,
async
()
=>
{
const
html1
=
await
(
await
fetchForTest
(
'/app/rsc-fetch'
)).
text
()
expect
(
html1
).
toContain
(
'<pre>test1</pre>'
)
const
html2
=
await
(
await
fetchForTest
(
'/app/rsc-fetch'
,
'test2'
)
).
text
()
expect
(
html2
).
toContain
(
'<pre>test2</pre>'
)
})
it
(
'should handle RSC with http.get in serverless function'
,
async
()
=>
{
const
html
=
await
(
await
fetchForTest
(
'/app/rsc-httpget'
)).
text
()
expect
(
html
).
toContain
(
'<pre>test1</pre>'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment