Unverified Commit dcc0ef8e authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Hide not ENOENT errors for not found in ipc server (#47854)

Not to log not found errors created from on demand handlers in ipc
server

Remove the not found error trace for dev
```
event - compiled client and server successfully in 57 ms (265 modules)
/Users/huozhi/workspace/next.js/packages/next/src/server/dev/on-demand-entry-handler.ts:450
    throw new PageNotFoundError(normalizedPagePath)
          ^

Error: Cannot find module for page: /not-found
    at findPagePathData (/Users/huozhi/workspace/next.js/packages/next/src/server/dev/on-demand-entry-handler.ts:450:11)
    at Object.ensurePage (/Users/huozhi/workspace/next.js/packages/next/src/server/dev/on-demand-entry-handler.ts:701:30)
    at Server.<anonymous> (/Users/huozhi/workspace/next.js/packages/next/src/server/lib/server-ipc.ts:29:24) {
  code: 'ENOENT'
}
```
parent 53ddfc83
......@@ -66,7 +66,7 @@ import {
import * as Log from '../../build/output/log'
import isError, { getProperError } from '../../lib/is-error'
import { getRouteRegex } from '../../shared/lib/router/utils/route-regex'
import { getSortedRoutes, isDynamicRoute } from '../../shared/lib/router/utils'
import { getSortedRoutes } from '../../shared/lib/router/utils'
import { runDependingOnPageType } from '../../build/entries'
import { NodeNextResponse, NodeNextRequest } from '../base-http/node'
import { getPageStaticInfo } from '../../build/analysis/get-page-static-info'
......@@ -797,7 +797,6 @@ export default class DevServer extends Server {
this.dynamicRoutes = sortedRoutes
.map((page) => {
if (!isDynamicRoute) return null
const regex = getRouteRegex(page)
return {
match: getRouteMatcher(regex),
......
......@@ -2,6 +2,7 @@ import type NextServer from '../next-server'
import { genExecArgv, getNodeOptionsWithoutInspect } from './utils'
import { deserializeErr, errorToJSON } from '../render'
import { IncomingMessage } from 'http'
import isError from '../../lib/is-error'
// we can't use process.send as jest-worker relies on
// it already and can cause unexpected message errors
......@@ -35,6 +36,9 @@ export async function createIpcServer(
res.end(JSON.stringify(result || ''))
}
} catch (err: any) {
if (isError(err) && err.code !== 'ENOENT') {
console.error(err)
}
res.end(
JSON.stringify({
err: { name: err.name, message: err.message, stack: err.stack },
......
......@@ -279,6 +279,13 @@ createNextDescribe(
'<meta name="viewport" content="width=device-width, initial-scale=1"/>'
)
})
it('should not log 404 errors in ipc server', async () => {
await next.fetch('/this-path-does-not-exist')
expect(next.cliOutput).not.toInclude(
'PageNotFoundError: Cannot find module for page'
)
})
})
}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment