-
Notifications
You must be signed in to change notification settings - Fork 73
Fix memory queue with deduplication and add basic test app #480
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 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ee3cea6
deduplicate using MessageDeduplicationId
conico974 3d21314
add test app for the memory-queue
conico974 856d166
small improvement to the memory-queue
conico974 5ce5496
linting
conico974 942159c
fix missing .js
conico974 31c8a6f
review
conico974 c59754e
fix flaky test
conico974 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
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,47 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/versions | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# env files (can opt-in for committing if needed) | ||
.env* | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# playwright | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
Binary file not shown.
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,14 @@ | ||
html, | ||
body { | ||
max-width: 100vw; | ||
overflow-x: hidden; | ||
height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
footer { | ||
padding: 1rem; | ||
display: flex; | ||
justify-content: end; | ||
} |
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,25 @@ | ||
import type { Metadata } from "next"; | ||
import "./globals.css"; | ||
|
||
import { getCloudflareContext } from "@opennextjs/cloudflare"; | ||
|
||
export const metadata: Metadata = { | ||
title: "SSG App", | ||
description: "An app in which all the routes are SSG'd", | ||
}; | ||
|
||
export default async function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
const cloudflareContext = await getCloudflareContext({ | ||
async: true, | ||
}); | ||
|
||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} |
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,17 @@ | ||
.page { | ||
display: grid; | ||
grid-template-rows: 20px 1fr 20px; | ||
align-items: center; | ||
justify-items: center; | ||
flex: 1; | ||
border: 3px solid gray; | ||
margin: 1rem; | ||
margin-block-end: 0; | ||
} | ||
|
||
.main { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 32px; | ||
grid-row-start: 2; | ||
} |
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,16 @@ | ||
import styles from "./page.module.css"; | ||
|
||
export const revalidate = 5; | ||
|
||
export default async function Home() { | ||
// We purposefully wait for 2 seconds to allow deduplication to occur | ||
await new Promise((resolve) => setTimeout(resolve, 2000)); | ||
return ( | ||
<div className={styles.page}> | ||
<main className={styles.main}> | ||
<h1>Hello from a Statically generated page</h1> | ||
<p data-testid="date-local">{Date.now()}</p> | ||
</main> | ||
</div> | ||
); | ||
} |
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,26 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.describe("memory-queue", () => { | ||
test("the index page should work", async ({ page }) => { | ||
await page.goto("/"); | ||
await expect(page.getByText("Hello from a Statically generated page")).toBeVisible(); | ||
}); | ||
|
||
test("the index page should revalidate", async ({ page }) => { | ||
await page.goto("/"); | ||
const firstDate = await page.getByTestId("date-local").textContent(); | ||
await page.waitForTimeout(5000); | ||
await page.reload(); | ||
|
||
let newDate = await page.getByTestId("date-local").textContent(); | ||
expect(newDate).toBe(firstDate); | ||
|
||
do { | ||
await page.reload(); | ||
newDate = await page.getByTestId("date-local").textContent(); | ||
await page.waitForTimeout(1000); | ||
} while (newDate === firstDate); | ||
|
||
expect(newDate).not.toBe(firstDate); | ||
}); | ||
}); |
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,8 @@ | ||
import { configurePlaywright } from "../../../common/config-e2e"; | ||
|
||
// Here we don't want to run the tests in parallel | ||
export default configurePlaywright("memory-queue", { | ||
isCI: !!process.env.CI, | ||
parallel: false, | ||
multipleBrowsers: false, | ||
}); |
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,11 @@ | ||
import type { NextConfig } from "next"; | ||
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare"; | ||
|
||
initOpenNextCloudflareForDev(); | ||
|
||
const nextConfig: NextConfig = { | ||
typescript: { ignoreBuildErrors: true }, | ||
eslint: { ignoreDuringBuilds: true }, | ||
}; | ||
|
||
export default nextConfig; |
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,8 @@ | ||
import { defineCloudflareConfig } from "@opennextjs/cloudflare"; | ||
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache"; | ||
import memoryQueue from "@opennextjs/cloudflare/memory-queue"; | ||
|
||
export default defineCloudflareConfig({ | ||
incrementalCache: kvIncrementalCache, | ||
queue: memoryQueue, | ||
}); |
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,28 @@ | ||
{ | ||
"name": "memory-queue", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint", | ||
"build:worker": "opennextjs-cloudflare", | ||
"preview": "pnpm build:worker && pnpm wrangler dev", | ||
"e2e": "playwright test -c e2e/playwright.config.ts" | ||
}, | ||
"dependencies": { | ||
"react": "^19.0.0", | ||
"react-dom": "^19.0.0", | ||
"next": "catalog:e2e" | ||
}, | ||
"devDependencies": { | ||
"@opennextjs/cloudflare": "workspace:*", | ||
"@playwright/test": "catalog:", | ||
"@types/node": "catalog:", | ||
"@types/react": "^19", | ||
"@types/react-dom": "^19", | ||
conico974 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"typescript": "catalog:", | ||
"wrangler": "catalog:" | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
], | ||
"paths": { | ||
"@/*": ["./*"] | ||
} | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
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,23 @@ | ||
{ | ||
"$schema": "node_modules/wrangler/config-schema.json", | ||
"main": ".open-next/worker.js", | ||
"name": "memory-queue", | ||
"compatibility_date": "2025-02-04", | ||
"compatibility_flags": ["nodejs_compat"], | ||
"assets": { | ||
"directory": ".open-next/assets", | ||
"binding": "ASSETS" | ||
}, | ||
"kv_namespaces": [ | ||
{ | ||
"binding": "NEXT_CACHE_WORKERS_KV", | ||
"id": "<BINDING_ID>" | ||
} | ||
], | ||
"services": [ | ||
{ | ||
"binding": "NEXT_CACHE_REVALIDATION_WORKER", | ||
"service": "memory-queue" | ||
} | ||
] | ||
} |
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.
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.