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
26aacb04
Unverified
Commit
26aacb04
authored
Apr 07, 2022
by
JJ Kasper
Committed by
GitHub
Apr 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure minimalMode previousCache expire time is capped (#35954)
parent
0164ac60
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
4 deletions
+62
-4
response-cache.ts
packages/next/server/response-cache.ts
+1
-4
required-server-files.test.ts
test/production/required-server-files.test.ts
+24
-0
gsp-long-revalidate.js
...uction/required-server-files/pages/gsp-long-revalidate.js
+37
-0
No files found.
packages/next/server/response-cache.ts
View file @
26aacb04
...
@@ -187,10 +187,7 @@ export default class ResponseCache {
...
@@ -187,10 +187,7 @@ export default class ResponseCache {
this
.
previousCacheItem
=
{
this
.
previousCacheItem
=
{
key
,
key
,
entry
:
cacheEntry
,
entry
:
cacheEntry
,
expiresAt
:
expiresAt
:
Date
.
now
()
+
1000
,
typeof
cacheEntry
.
revalidate
!==
'number'
?
Date
.
now
()
+
1000
:
Date
.
now
()
+
cacheEntry
?.
revalidate
*
1000
,
}
}
}
else
{
}
else
{
await
this
.
incrementalCache
.
set
(
await
this
.
incrementalCache
.
set
(
...
...
test/production/required-server-files.test.ts
View file @
26aacb04
...
@@ -211,6 +211,30 @@ describe('should set-up next', () => {
...
@@ -211,6 +211,30 @@ describe('should set-up next', () => {
expect
(
props4
.
gspCalls
).
toBe
(
props3
.
gspCalls
)
expect
(
props4
.
gspCalls
).
toBe
(
props3
.
gspCalls
)
})
})
it
(
'should cap de-dupe previousCacheItem expires time'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
appPort
,
'/gsp-long-revalidate'
,
undefined
,
{
redirect
:
'manual'
,
})
expect
(
res
.
status
).
toBe
(
200
)
const
$
=
cheerio
.
load
(
await
res
.
text
())
const
props
=
JSON
.
parse
(
$
(
'#props'
).
text
())
expect
(
props
.
gspCalls
).
toBeDefined
()
await
waitFor
(
1000
)
const
res2
=
await
fetchViaHTTP
(
appPort
,
`/_next/data/
${
next
.
buildId
}
/gsp-long-revalidate.json`
,
undefined
,
{
redirect
:
'manual'
,
}
)
expect
(
res2
.
status
).
toBe
(
200
)
const
{
pageProps
:
props2
}
=
await
res2
.
json
()
expect
(
props2
.
gspCalls
).
not
.
toBe
(
props
.
gspCalls
)
})
it
(
'should set correct SWR headers with notFound gsp'
,
async
()
=>
{
it
(
'should set correct SWR headers with notFound gsp'
,
async
()
=>
{
await
waitFor
(
2000
)
await
waitFor
(
2000
)
await
next
.
patchFile
(
'standalone/data.txt'
,
'show'
)
await
next
.
patchFile
(
'standalone/data.txt'
,
'show'
)
...
...
test/production/required-server-files/pages/gsp-long-revalidate.js
0 → 100644
View file @
26aacb04
import
fs
from
'fs'
import
path
from
'path'
let
gspCalls
=
0
export
async
function
getStaticProps
()
{
const
data
=
await
fs
.
promises
.
readFile
(
path
.
join
(
process
.
cwd
(),
'data.txt'
),
'utf8'
)
gspCalls
+=
1
if
(
data
.
trim
()
===
'hide'
)
{
return
{
notFound
:
true
,
revalidate
:
1
,
}
}
return
{
props
:
{
hello
:
'world'
,
data
,
gspCalls
,
},
revalidate
:
100
,
}
}
export
default
function
Page
(
props
)
{
return
(
<>
<
p
id
=
"gsp"
>
getStaticProps
page
<
/p
>
<
p
id
=
"props"
>
{
JSON
.
stringify
(
props
)}
<
/p
>
<
/
>
)
}
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