Next.js Pages Router - fallback: false not respected

Sitename: https://beautifulbiology.netlify.app

Hello! I’m working on a site that’s using Next.js 13.4.12 with the pages folder routing approach.
I have dynamic routes, and I’ve set fallback: false in all getStaticPaths functions.

However, when navigating to a page that doesn’t exist, the SSR handler function is still being hit, and sometimes throws a lamda function timeout error.

As far as I understand, this should not be the case, and any routes that aren’t generated within getStaticPaths functions should automatically navigate to the 404 page without any need for SSR.

SSR Function logs:

Dec 7, 02:09:41 PM: ddc6023d INFO Downloading https://beautifulbiology.netlify.app/404.html from CDN to /tmp/next-static-cache/pages/404.html

Dec 7, 02:09:41 PM: ddc6023d INFO Downloading https://beautifulbiology.netlify.app/_next/data/NAGbsVlg6IcZSCQ-tqWpk/404.json from CDN to /tmp/next-static-cache/pages/404.json

Dec 7, 02:09:41 PM: ddc6023d INFO [GET] /contributor/media-detail/add/nQCPesz5rBA7wXzVrMleVLU7ZMqHUT0l (SSR)

Dec 7, 02:09:46 PM: ddc6023d Duration: 3581.46 ms Memory Usage: 164 MB Init Duration: 664.00 ms

Dec 7, 02:51:07 PM: 1227c5da 2023-12-07T20:51:18.288Z 1227c5da-0eae-43f1-8261-ce0b6283d63b Task timed out after 10.02 seconds

Dec 7, 02:51:17 PM: 1227c5da Duration: 10017.96 ms Memory Usage: 162 MB Init Duration: 597.03 ms

Dec 7, 02:53:45 PM: 6aa34b95 INFO Downloading https://beautifulbiology.netlify.app/404.html from CDN to /tmp/next-static-cache/pages/404.html

Dec 7, 02:53:45 PM: 6aa34b95 INFO Downloading https://beautifulbiology.netlify.app/_next/data/NAGbsVlg6IcZSCQ-tqWpk/404.json from CDN to /tmp/next-static-cache/pages/404.json

Dec 7, 02:53:45 PM: 6aa34b95 INFO [GET] /contributor/media-detail/add/nQCPesz5rBA7wXzVrMleVLU7ZMqHUT0l (SSR)

Dec 7, 02:53:48 PM: 6aa34b95 Duration: 2981.99 ms Memory Usage: 96 MB

Dec 7, 03:40:29 PM: def2c22d 2023-12-07T21:40:40.807Z def2c22d-c782-4fac-bda8-4547fb671f9b Task timed out after 10.03 seconds

Dec 7, 03:40:39 PM: def2c22d Duration: 10032.80 ms Memory Usage: 159 MB Init Duration: 557.25 ms

Dec 7, 03:48:10 PM: d50685fb INFO Downloading https://beautifulbiology.netlify.app/404.html from CDN to /tmp/next-static-cache/pages/404.html

Dec 7, 03:48:10 PM: d50685fb INFO Downloading https://beautifulbiology.netlify.app/_next/data/l7vFFyiWbswe14H75bL_I/404.json from CDN to /tmp/next-static-cache/pages/404.json

Dec 7, 03:48:10 PM: d50685fb INFO [GET] /contributor/media-detail/add/nQCPesz5rBA7wXzVrMleVLU7ZMqHUT0l (SSR)

Dec 7, 03:48:14 PM: d50685fb Duration: 3591.41 ms Memory Usage: 144 MB Init Duration: 598.62 ms

Dec 7, 03:50:20 PM: b6bd3243 INFO [GET] /contributor/jkljklklj (SSR)

Dec 7, 03:50:20 PM: b6bd3243 Duration: 658.57 ms Memory Usage: 146 MB

Dec 7, 03:51:10 PM: f38586f2 INFO [GET] /media-details/asdfffa (SSR)

Dec 7, 03:51:10 PM: f38586f2 Duration: 633.38 ms Memory Usage: 147 MB

That’s not true. At the moment, on Netlify, everything that’s 404 first goes through SSR handler and then shows a 404 if needed. This is intended.

1 Like

Oh, that’s surprising. Is that something only Netlify does?

Also, why would we experience lambda function timeouts? Is Netlify trying to run one of our […slug] page’s “getStaticProps” functions before navigating to the 404 page?

I appreciate your help!

More like “has to do”. The way the platform is laid out currently needs us to invoke the function to make sure Next.js gets a chance to handle the request. This is already being worked upon though and should not be the case in some future iterations.

That, I cannot answer as I have no idea about your project, setup or the codebase. You’d have to find out using the good old console logs: [Support Guide] Why is my function taking long or timing out?

1 Like

Thank you for clearing my questions up! I appreciate all the help you provide on here.