Skip to content

Commit 67d0701

Browse files
committed
reduce time and add better comment
1 parent b16fd3f commit 67d0701

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/app-pages-router/middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import type { NextRequest } from "next/server";
22
import { NextResponse } from "next/server";
33

44
// Needed to test top-level await
5+
// We are using `setTimeout` to simulate a "long" running operation
6+
// we could have used `Promise.resolve` instead, but it would be running in a different way in the event loop
57
// @ts-expect-error - It will cause a warning at build time, but it should just work
68
const topLevelAwait = await new Promise<string>((resolve) => {
79
setTimeout(() => {
810
resolve("top-level-await");
9-
}, 150);
11+
}, 10);
1012
});
1113

1214
export function middleware(request: NextRequest) {

0 commit comments

Comments
 (0)