Skip to content

Commit 8423b74

Browse files
add counter?
1 parent 11e6545 commit 8423b74

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

e2e/react-start/server-functions/src/routes/middleware/retry-next.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { createFileRoute } from '@tanstack/react-router'
22
import { createMiddleware, createServerFn } from '@tanstack/react-start'
33

4+
let count = 0
5+
46
const retryMiddleware = createMiddleware({ type: 'function' })
57
.client(async ({ next }) => {
68
await next()
@@ -14,7 +16,11 @@ const retryMiddleware = createMiddleware({ type: 'function' })
1416
const serverFn = createServerFn()
1517
.middleware([retryMiddleware])
1618
.handler(() => {
17-
return 'success'
19+
// Reset count when called a second time
20+
if (count == 4) {
21+
count = 0
22+
}
23+
return `called ${++count} times`
1824
})
1925

2026
export const Route = createFileRoute('/middleware/retry-next')({

e2e/react-start/server-functions/tests/server-functions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ test.describe('middleware', () => {
376376
async function runRetryTest(page: Page) {
377377
await page.waitForLoadState('networkidle')
378378
await expect(page.getByTestId('retry-success-result')).toContainText(
379-
'success',
379+
'called 4 times',
380380
)
381381
}
382382

0 commit comments

Comments
 (0)