Local functions and `netlify dev` = TypeError and crash

I’m having quite a frustrating time debugging some netlify functions within netlify dev. To isolate variables, I made a very simple (typescript) function that contained the example ‘hello world’ function from this page. I called it test.ts. And I invoked it in the browser. And then, it immediately crashes:


   ┌──────────────────────────────────────────────────┐
   │                                                  │
   │   ◈ Server now ready on http://localhost:38979   │
   │                                                  │
   └──────────────────────────────────────────────────┘

Request from ::1: GET /.netlify/functions/test
TypeError: Cannot destructure property 'inputs' of '(intermediate value)' as it is undefined.
    at buildFunction (/home/mfan/projects/example0012/node_modules/netlify-cli/src/lib/functions/runtimes/js/builders/zisi.js:39:11)
    at NetlifyFunction.build (/home/mfan/projects/example0012/node_modules/netlify-cli/src/lib/functions/netlify-function.js:50:42)
    at FunctionsRegistry.buildFunctionAndWatchFiles (/home/mfan/projects/example0012/node_modules/netlify-cli/src/lib/functions/registry.js:69:38)
TypeError: Cannot destructure property 'inputs' of '(intermediate value)' as it is undefined.
    at buildFunction (/home/mfan/projects/example0012/node_modules/netlify-cli/src/lib/functions/runtimes/js/builders/zisi.js:39:11)
    at NetlifyFunction.build (/home/mfan/projects/example0012/node_modules/netlify-cli/src/lib/functions/netlify-function.js:50:42)
    at FunctionsRegistry.buildFunctionAndWatchFiles (/home/mfan/projects/example0012/node_modules/netlify-cli/src/lib/functions/registry.js:69:38)

/home/mfan/projects/example0012/node_modules/netlify-redirector/lib/redirects.js:116
      throw ex;
      ^
abort({}) at Error: 
    at jsStackTrace (/home/mfan/projects/example0012/node_modules/netlify-redirector/lib/redirects.js:1070:13)
    at stackTrace (/home/mfan/projects/example0012/node_modules/netlify-redirector/lib/redirects.js:1087:12)
    at process.abort (/home/mfan/projects/example0012/node_modules/netlify-redirector/lib/redirects.js:8502:44)
    at process.emit (events.js:375:28)
    at processEmit [as emit] (/home/mfan/projects/example0012/node_modules/signal-exit/index.js:175:34)
    at processPromiseRejections (internal/process/promises.js:245:33)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)
(Use `node --trace-uncaught ...` to show where the exception was thrown)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is a Gatsby 3 site, for which I’m using the /api folder successfully, but I’m needing to also add some netlify functions to respond to events (submission created, etc.).

Just in case, I’ve already updated my dependencies to the latest netlify and netlify-cli. Is there any reason why this might be occurring? Or a way I could start to debug this? The function works as intended once pushed to Netlify.

1 Like

Hi @mfan,

Could we get a repo to test this?

@hrishikesh
Here’s a repro repo - I get it just from having the boilerplate function code from the typescript announcement

Turns out the solution was to remove the trailing slash from the functions folder path in the netlify.toml file

2 Likes

Thanks for the solution!

1 Like