Description
Describe the bug
I have a function named "index" that uses serverless to return a Koa app. The function builds successfully and starts using dev. If I make requests against the root endpoint using a tool like postman, the cli will crash after the second request completes. It crashes in the browser too but it's easier to see the behavior in a tool that makes a single request.
Steps to reproduce
git clone https://codeberg.org/rlmcneary2/funcstache-website.git
- Switch to branch "cli-crash"
npm i
npm run build && npm run dev
- Open a tool like postman or rested and send a request to "http://localhost:8888/"
- Send the request again.
Following the second request others will fail because the cli process has exited.
◈ Rewrote URL to /.netlify/functions/index/
Request from 127.0.0.1: GET /.netlify/functions/index/
--- index: ENTER[catcher] status=404
--- index: ENTER[funcstache] status=404
funcstache(middleware): url='/'
funcstache(middleware): requestedUrl='site/'
--- index: koa app started; http://localhost:3000
getTemplatePartials: source template='layout', add to pending: { sourceTemplateDir: '', templateFilename: '', templateName: 'main' }
getTemplatePartials: source template='layout', add to pending: {
sourceTemplateDir: './layouts/default',
templateFilename: '../../shared/nav/nav',
templateName: 'navItems'
}
readTemplateFile: templateName='navItems', sourceTemplateDir='./layouts/default'
readTemplateFile: templateName='main', sourceTemplateDir=''
readTemplateFile: templateName='layout', sourceTemplateDir=''
funcstache(middleware): url='/'; exit
--- index: EXIT[funcstache] status=200
--- index: EXIT[catcher] status=200
Response with status 200 in 68 ms.
◈ Rewrote URL to /.netlify/functions/index/
Request from 127.0.0.1: GET /.netlify/functions/index/
--- index: ENTER[catcher] status=404
--- index: ENTER[funcstache] status=404
funcstache(middleware): url='/'
funcstache(middleware): requestedUrl='site/'
› Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:
npm install -g netlify-cli@VERSION
You can use any version from https://ntl.fyi/cli-versions.
Please report this problem at https://ntl.fyi/cli-error including the error details below.
getTemplatePartials: source template='layout', add to pending: { sourceTemplateDir: '', templateFilename: '', templateName: 'main' }
getTemplatePartials: source template='layout', add to pending: {
sourceTemplateDir: './layouts/default',
templateFilename: '../../shared/nav/nav',
templateName: 'navItems'
}
readTemplateFile: templateName='navItems', sourceTemplateDir='./layouts/default'
readTemplateFile: templateName='main', sourceTemplateDir=''
readTemplateFile: templateName='layout', sourceTemplateDir=''
funcstache(middleware): url='/'; exit
--- index: EXIT[funcstache] status=200
--- index: EXIT[catcher] status=200
Response with status 200 in 42 ms.
Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
at Server.setupListenHandle [as _listen2] (node:net:1904:16)
at listenInCluster (node:net:1961:12)
at GetAddrInfoReqWrap.doListen (node:net:2135:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:8)
System:
OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Binaries:
Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
Browsers:
Chrome: 113.0.5672.63
Requests against the "images" function in the environment (a standard synchronous function) never fail.
Configuration
[build]
environment = { NODE_VERSION = "20.16.0" }
[dev]
autoLaunch = false
[context.dev]
publish = "."
[functions."images"]
included_files = ["./images/**"]
[functions."index"]
included_files = ["./site/**"]
[[redirects]]
force = true
from = "/favicon.ico"
status = 200
to = "/images/favicon.ico"
[[redirects]]
force = true
from = "/images/*"
status = 200
to = "/.netlify/functions/images/:splat"
[[redirects]]
force = true
from = "/*"
status = 200
to = "/.netlify/functions/index/:splat"
Environment
Ubuntu running in WSL2.
System:
OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 4.96 GB / 7.61 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
npmPackages:
netlify-cli: ^17.36.2 => 17.36.2