Have to restart local devserver manually when we change code

Hi, our local dev server is broken on latest stable v7.7.4.
This is happening for all devs.

api | 09:37:05 🌲 Server listening at http://localhost:8911
api | Took 2836 ms
api | API server listening at http://localhost:8911/
api | GraphQL endpoint at http://localhost:8911/graphql
api | [change] /src/services/tasks/tasks.ts
api | Building...
api | Took 4052 ms
api | Starting inspector on 127.0.0.1:18911 failed: address already in use
api | Starting API Server...
api | Importing Server Functions... 
api | [hive] Missing token, disabling.
api | /graphql 2609 ms
api | ...Done importing in 2610 ms
api | rw-server api
api | 
api | Start a server for serving the api side
api | 
api | Options:
api |   -p, --port                                The port to listen at       [number]
api |       --host                                The host to listen at. Note that you
api |                                             most likely want this to be
api |                                             '0.0.0.0' in production     [string]
api |       --apiRootPath, --api-root-path,       Root path where your api functions
api |       --rootPath, --root-path               are served   [string] [default: "/"]
api |   -h, --help                                Show help                  [boolean]
api |   -v, --version                             Show version number        [boolean]
api | 
api | Error: listen EADDRINUSE: address already in use :::8911
api |     at Server.setupListenHandle [as _listen2] (node:net:1898:16)
api |     at listenInCluster (node:net:1946:12)
api |     at doListen (node:net:2116:7)
api |     at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
api |   code: 'EADDRINUSE',
api |   errno: -48,
api |   syscall: 'listen',
api |   address: '::',
api |   port: 8911
api | }
^Cweb | yarn cross-env NODE_ENV=development rw-vite-dev  exited with code 0
gen | yarn rw-gen-watch exited with code 130

Hi @jonoc330,

We have had this issue too and discussed it in the v7.0.0 Upgrade guide and @callingmedic911 made a fix for the issue here.

As far as I can tell from the GitHub PR linked in the post above and the early release candidate for v8.0.0, this fix, unfortunately, won’t be live until we get v8 :pensive:

I have found that the best way to avoid the issue is to disable auto-save in your editor because it will trigger multiple rebuilds if you make many consecutive file changes in the backend. Also, if you switch between branches where there are multiple file changes in the backend, then you’re better off restarting the dev server completely.

Hey @lars I’ve upgrade to v8 and I’m still getting this issue

Are you using Windows/Linux/MacOS? I have moved from Windows to Linux and have rarely experienced the issue since then. I wasn’t able to reproduce the error on our branch that upgrades to v8

On MacOS

@jonoc330 Does this happen with every change?

It’s possible that when restarting the API server, if killing the existing server takes too long, it could cause this problem. This is just a hypothesis though, and I imagine it would be infrequent.

Do you have a reproduction by any chance? I have a potential fix in mind but wanted to confirm this hypothesis before proceeding.

Hey @callingmedic911 I’ve tried to repro it but can’t seem to. Correct it happens on every change. We have a really large application, it typically takes about 5-10 seconds to build and restart, just as an idea.
We have 31 functions which i’ve redacted below for reference

web |   ➜  Local:   http://localhost:8910/
web |   ➜  Network: http://192.168.3.1:8910/
web |   ➜  Network: http://192.168.50.151:8910/
web |   ➜  Network: http://192.168.2.1:8910/
gen | Generating full TypeScript definitions and GraphQL schemas
gen | Done.
api | Building...
api | Took 5057 ms
api | Debugger listening on ws://127.0.0.1:18911/cda49a28-73d1-40bd-be72-1f4701052366
api | For help, see: https://nodejs.org/en/docs/inspector
api | Starting API Server...
api | Importing Server Functions... 
api | /graphql 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /<function_name (redacted)> 2388 ms
api | /workflowRunner 2388 ms
api | ...Done importing in 2391 ms
api | [hive] Missing token, disabling.
api | GraphQL Yoga Server endpoint at graphql
api | GraphQL Yoga Server Health Check endpoint at graphql/health
api | GraphQL Yoga Server Readiness endpoint at graphql/readiness
api | 09:50:11 🌲 Server listening at http://[::]:8911
api | Server listening at http://[::]:8911/
api | Took 3749 ms
api | API server listening at http://localhost:8911/
api | GraphQL endpoint at http://localhost:8911/graphql