Hi,
I’ve been building React apps without any issues for a long time. Suddenly, the netlify-cli crashed just after unzipping a function.
I started getting this weird error:
Warning: TypeError: Cannot read properties of undefined (reading 'routes')
At first, I thought it was related to an update I did in the UI part and that, for some reason, the BrowserRouter was broken.
Removing it completely from the project didn’t help, though.
So, I enabled debug logging by passing the --debug argument like so:
netlify dev --debug
This gave me the place where it all crashed:
› Warning: TypeError: Cannot read properties of undefined (reading 'routes')
› at FunctionsRegistry.registerFunction (file:///usr/local/lib/node_modules/netlify-cli/src/lib/functions/registry.js:321:39)
› at async file:///usr/local/lib/node_modules/netlify-cli/src/lib/functions/registry.js:423:13
› at async Promise.all (index 27)
› at async FunctionsRegistry.scan (file:///usr/local/lib/node_modules/netlify-cli/src/lib/functions/registry.js:386:32)
› at async startFunctionsServer (file:///usr/local/lib/node_modules/netlify-cli/src/lib/functions/server.js:274:5)
› at async BaseCommand.dev (file:///usr/local/lib/node_modules/netlify-cli/src/commands/dev/dev.js:126:31)
› at async BaseCommand.parseAsync (/usr/local/lib/node_modules/netlify-cli/node_modules/commander/lib/command.js:935:5)
› at async file:///usr/local/lib/node_modules/netlify-cli/bin/run.js:27:3
I dove into the code and changed it from this (I added the arrow with ‘culprit’ for clarity):
func.buildData = {
...manifestEntry?.buildData,
routes: manifestEntry.routes, <--- culprit
};
To this:
func.buildData = {
...manifestEntry?.buildData,
routes: manifestEntry?.routes,
};
The CLI no longer crashes, and my React app launches like before.
My question is, should I somehow add mainfest.json files to my project? Is it because I forgot some options? Or is this just a small bug?