Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 82 additions & 82 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"homepage": "https://opennext.js.org/netlify",
"devDependencies": {
"@fastly/http-compute-js": "1.1.5",
"@netlify/blobs": "^8.2.0",
"@netlify/blobs": "^10.1.0",
"@netlify/build": "^35.1.7",
"@netlify/config": "^24.0.4",
"@netlify/edge-bundler": "^14.5.5",
Expand Down
32 changes: 16 additions & 16 deletions tests/integration/cache-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('page router', () => {
countOfBlobServerGetsForKey(ctx, '/static/revalidate-automatic'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// wait to have page regenerated in the background
await new Promise<void>((resolve) => setTimeout(resolve, 1000))
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('page router', () => {
countOfBlobServerGetsForKey(ctx, '/static/revalidate-automatic'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// ping that should serve the stale page for static/revalidate-slow, while revalidating in background
await invokeFunction(ctx, { url: 'static/revalidate-slow' })
Expand All @@ -125,7 +125,7 @@ describe('page router', () => {
countOfBlobServerGetsForKey(ctx, '/static/revalidate-slow'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// wait to have a stale page
await new Promise<void>((resolve) => setTimeout(resolve, 6_000))
Expand All @@ -136,7 +136,7 @@ describe('page router', () => {
countOfBlobServerGetsForKey(ctx, '/static/revalidate-slow'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// over 5 seconds since it was regenerated, so we should get stale response,
// while fresh is generated in the background
Expand All @@ -160,7 +160,7 @@ describe('page router', () => {
countOfBlobServerGetsForKey(ctx, '/static/revalidate-automatic'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// Slow revalidate should still be a hit, but the maxage should be updated
const callLater2 = await invokeFunction(ctx, { url: 'static/revalidate-slow' })
Expand All @@ -177,7 +177,7 @@ describe('page router', () => {
countOfBlobServerGetsForKey(ctx, '/static/revalidate-slow'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// it does not wait for the cache.set so we have to manually wait here until the blob storage got populated
await new Promise<void>((resolve) => setTimeout(resolve, 1000))
Expand All @@ -204,7 +204,7 @@ describe('page router', () => {
countOfBlobServerGetsForKey(ctx, '/static/revalidate-automatic'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()
})
})

Expand Down Expand Up @@ -245,7 +245,7 @@ describe('app router', () => {
countOfBlobServerGetsForKey(ctx, '/posts/1'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// test a prerendered page without TTL
const post2 = await invokeFunction(ctx, { url: '/' })
Expand All @@ -263,7 +263,7 @@ describe('app router', () => {
countOfBlobServerGetsForKey(ctx, '/index'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

expect(await ctx.blobStore.get(encodeBlobKey('/posts/3'))).toBeNull()
// this page is not pre-rendered and should result in a cache miss
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('app router', () => {
countOfBlobServerGetsForKey(ctx, '/posts/1'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()
// it should've been regenerated in the background after the first call
// so the date should be different
expect(staleDate, 'the date was cached and is matching the initial one').not.toBe(post1Date)
Expand All @@ -320,7 +320,7 @@ describe('app router', () => {
countOfBlobServerGetsForKey(ctx, '/posts/1'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()
})

test<FixtureTestContext>("not-prerendered pages should be permanently cached when produced by sandboxed invocations that don't share memory", async (ctx) => {
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('route', () => {
})
expect(blobEntry).not.toBeNull()

ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// test the first invocation of the route - we should get stale response while fresh is generated in the background
const call1 = await invokeFunction(ctx, { url: '/api/revalidate-handler' })
Expand All @@ -428,7 +428,7 @@ describe('route', () => {
countOfBlobServerGetsForKey(ctx, '/api/revalidate-handler'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// it does not wait for the cache.set so we have to manually wait here until the blob storage got populated
await new Promise<void>((resolve) => setTimeout(resolve, 1000))
Expand Down Expand Up @@ -458,7 +458,7 @@ describe('route', () => {
countOfBlobServerGetsForKey(ctx, '/api/revalidate-handler'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// wait to have a stale route again
await new Promise<void>((resolve) => setTimeout(resolve, 8_000))
Expand All @@ -485,7 +485,7 @@ describe('route', () => {
countOfBlobServerGetsForKey(ctx, '/api/revalidate-handler'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

// it does not wait for the cache.set so we have to manually wait here until the blob storage got populated
await new Promise<void>((resolve) => setTimeout(resolve, 1000))
Expand All @@ -510,7 +510,7 @@ describe('route', () => {
countOfBlobServerGetsForKey(ctx, '/api/revalidate-handler'),
'should only try to get value once from blob store (date calculation should not trigger additional blobs.get)',
).toBe(1)
ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()
})

test<FixtureTestContext>('cacheable route handler response not produced at build is served correctly', async (ctx) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/fetch-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ test<FixtureTestContext>('does not fetch same cached fetch data from blobs twice
'expected blobs for all types of values to be retrieved at most once per key (including fetch data, tag manifests, static files)',
).toBeDistinct()

ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()
handlerCalled = 0
const request2 = await invokeFunction(ctx, {
url: 'same-fetch-multiple-times/99',
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/request-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('request-context does NOT leak between concurrent requests', () => {
lastModified: new Date(mockedDateForRevalidateSlow).getTime(),
})

ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

const waitForCacheHandlerGetAndPausePromise =
waitForCacheHandlerGetAndPause('/static/revalidate-slow')
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('request-context does NOT leak between concurrent requests', () => {
lastModified: new Date(mockedDateForStaticFetch2).getTime(),
})

ctx.blobServerGetSpy.mockClear()
ctx.blobServerOnRequestSpy.mockClear()

const waitForCacheHandlerGetAndPausePromise = waitForCacheHandlerGetAndPause('/static-fetch/2')
const slowCallPromise = invokeFunction(ctx, {
Expand Down
Loading
Loading