Repository: vercel/next.js
Pull request: Routing: Clean up some code

## What?

Small cleanups, variable names / unused code. No functional changes.

Closes PACK-5110

Changed files:
filename: packages/next/src/server/lib/router-utils/filesystem.ts
patch: @@ -659,16 +659,19 @@ export async function setupFsCheck(opts: {
               }
             } else if (type === 'pageFile' || type === 'appFile') {
               const isAppFile = type === 'appFile'
-              if (
-                ensureFn &&
-                (await ensureFn({
-                  type,
-                  itemPath: isAppFile
-                    ? normalizeMetadataRoute(curItemPath)
-                    : curItemPath,
-                })?.catch(() => 'ENSURE_FAILED')) === 'ENSURE_FAILED'
-              ) {
-                continue
+
+              // Attempt to ensure the page/app file is compiled and ready
+              if (ensureFn) {
+                const ensureItemPath = isAppFile
+                  ? normalizeMetadataRoute(curItemPath)
+                  : curItemPath
+
+                try {
+                  await ensureFn({ type, itemPath: ensureItemPath })
+                } catch (error) {
+                  // If ensure failed, skip this item and continue to the next one
+                  continue
+                }
               }
             } else {
               continue

filename: packages/next/src/server/lib/router-utils/resolve-routes.ts
patch: @@ -324,7 +324,7 @@ export function getResolveRoutes(
     }
 
     async function handleRoute(
-      route: (typeof routes)[0]
+      route: Route
     ): Promise<UnwrapPromise<ReturnType<typeof resolveRoutes>> | void> {
       let curPathname = parsedUrl.pathname || '/'
 

filename: packages/next/src/server/route-matcher-managers/dev-route-matcher-manager.ts
patch: @@ -71,19 +71,19 @@ export class DevRouteMatcherManager extends DefaultRouteMatcherManager {
 
     // Iterate over the development matches to see if one of them match the
     // request path.
-    for await (const development of super.matchAll(pathname, options)) {
+    for await (const developmentMatch of super.matchAll(pathname, options)) {
       // We're here, which means that we haven't seen this match yet, so we
       // should try to ensure it and recompile the production matcher.
-      await this.ensurer.ensure(development, pathname)
+      await this.ensurer.ensure(developmentMatch, pathname)
       await this.production.reload()
 
       // Iterate over the production matches again, this time we should be able
       // to match it against the production matcher unless there's an error.
-      for await (const production of this.production.matchAll(
+      for await (const productionMatch of this.production.matchAll(
         pathname,
         options
       )) {
-        yield production
+        yield productionMatch
       }
     }
 

filename: packages/next/src/server/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts
patch: @@ -4,7 +4,7 @@ import { recursiveReadDir } from '../../../../../lib/recursive-readdir'
 
 export type DefaultFileReaderOptions = Pick<
   RecursiveReadDirOptions,
-  'pathnameFilter' | 'ignoreFilter' | 'ignorePartFilter'
+  'pathnameFilter' | 'ignorePartFilter'
 >
 
 /**
@@ -39,7 +39,6 @@ export class DefaultFileReader implements FileReader {
   public async read(dir: string): Promise<ReadonlyArray<string>> {
     return recursiveReadDir(dir, {
       pathnameFilter: this.options.pathnameFilter,
-      ignoreFilter: this.options.ignoreFilter,
       ignorePartFilter: this.options.ignorePartFilter,
 
       // We don't need to sort the results because we're not depending on the