Next.js: client pings, but there's no entry for page

Created on 25 Jun 2019  路  14Comments  路  Source: vercel/next.js

Bug report

Describe the bug

I keep getting this message since I added a custom server. I read many links where it says it may be related to using Link without as but it's not my case. i used the custom-server-typescript as an example but using typescript.
The issue I have is that the server keeps restarting and it gets stuck at restarting. The message is Restarting: /.../.next/server/static/development/pages/cart.js has been modified

this is my tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "jsx": "preserve",
    "lib": ["dom", "es2017"],
    "moduleResolution": "node",
    "strict": true,
    "allowJs": true,
    "noEmit": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "isolatedModules": true,
    "preserveConstEnums": true,
    "sourceMap": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "resolveJsonModule": true
  },
  "exclude": [
    "node_modules",
    "dist",
    ".next",
    "out",
    "next.config.js",
    "apollo.config.js"
  ],
  "include": ["**/*.ts", "**/*.tsx"]
}

and this is the tsconfig.server.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "dist",
    "target": "es2017",
    "isolatedModules": false,
    "noEmit": false
  },
  "exclude": [
    "node_modules",
    "dist",
    ".next",
    "out",
    "next.config.js",
    "apollo.config.js"
  ],
  "include": ["server/**/*.ts"]
}

and this is my server.ts

import express from 'express';
import next from 'next/dist/server/next';

const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();

app
  .prepare()
  .then(() => {
    const server = express();

    server.get('/category/:id', (req, res) => {
      const actualPage = '/category';
      const queryParams = { id: req.params.id };
      app.render(req, res, actualPage, queryParams);
    });

    server.get('/product/:id', (req, res) => {
      const actualPage = '/product';
      const queryParams = { id: req.params.id };
      app.render(req, res, actualPage, queryParams);
    });

    server.get('/order/:id', (req, res) => {
      const actualPage = '/order';
      const queryParams = { id: req.params.id };
      app.render(req, res, actualPage, queryParams);
    });

    server.get('*', (req, res) => {
      return handle(req, res);
    });

    server.listen(3000, err => {
      if (err) throw err;
      console.log('> Ready on http://localhost:3000');
    });
  })
  .catch(ex => {
    console.error(ex.stack);
    process.exit(1);
  });

start script

ts-node-dev --project tsconfig.server.json --no-notify --respawn --transpileOnly server/index.ts

I'm also seeing this errors an warnnigs in the console

image

To Reproduce

I'm basically using the custom-server-typescript example and using express for the server. I'm also using react-apollo v3

System information

  • OS: macOS
  • Version of Next.js: 8.1.1-canary.28

Additional context

The cart page where I see this error has no query parameters. Is not the only page I see the error, but I just wanted to pointed it out that I have no need to use Link with parameters and use as in this case

This only happens when running the custom server. Otherwise everything works fine

Do I need to include the pages that not require parameters to the custom server routes? Or do I need to set the as parameter to the Link component even if I don't need parameters in the page?

All 14 comments

Could you provide a full reproduction repository? It's quite a lot of work to reproduce based on the instructions you've given.

I created a repo here

they way to reproduce the error is by running the app, navigate a few pages and wait about a minute it will try to auto restart. Sometimes it will show a loading spinner even tho you can still navigate through the pages

I have encountered the same problem. I simply forked https://github.com/zeit/next.js/tree/canary/examples/custom-server, and the only thing I have changed is making port 3000 to 4000.

The steps are:

  1. run npm run dev before visiting the page.
  2. visit the page.
  3. stop it and run npm run dev again.

image

Run it with a different port fixed the problem at first. But the error shows again if re-proceed the steps above.

I also noticed when visiting the page, it hangs forever.

image

node v10.10.0
mac Mojave

 "next": "latest",

also

"next": "^8.1.0",

Same issue for me but I have customized App component by simply copying and pasting a piece of code provided in the documentation. Once I remove ./pages/_app.js everything becomes fine again.

@ambertino please provide a minimal reproduction

@timneutkens, I resolved it. I had screwed up next.config.js: overwritten default aliases. So all good now.

@timneutkens I have already created a repo to reproduce this issue as @curran requested it

@timneutkens and I have already written down the steps to reproduce the issue with the official example repository

I can't reproduce this.

@timneutkens have you tried the repo I created?

I also face problem .
output of terminal :
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:3000 ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000

[ event ] client pings, but there's no entry for page: /_error
[ event ] disposing inactive page(s): /next/dist/pages/_error
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ event ] disposing inactive page(s): /next/dist/pages/_error
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ event ] disposing inactive page(s): /next/dist/pages/_error
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ event ] disposing inactive page(s): /next/dist/pages/_error
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ event ] disposing inactive page(s): /next/dist/pages/_error
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
[ event ] disposing inactive page(s): /next/dist/pages/_error
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000


Screen Shot 1398-06-22 at 18 06 29
Screen Shot 1398-06-22 at 18 10 25

any solutions?

any solutions?

@szczepcio95 this comment is not helpful

  • Same as saying +1, so you can use emoji reactions
  • Does not provide any reproduction
  • Is not actionable

In my particular case the issue has been causing by having Next.js v7. By running npm install with Next.js v9 everything started to work again.

Was this page helpful?
0 / 5 - 0 ratings