Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Server is killed and doesn't come back up when saving changes #11719

Closed
1 task
o0charlie0o opened this issue Nov 15, 2024 · 6 comments · Fixed by #11731
Closed
1 task

[Bug?]: Server is killed and doesn't come back up when saving changes #11719

o0charlie0o opened this issue Nov 15, 2024 · 6 comments · Fixed by #11731
Labels
bug/needs-info More information is needed for reproduction

Comments

@o0charlie0o
Copy link
Contributor

o0charlie0o commented Nov 15, 2024

What's not working?

When the server restarts after making a code change it is killed and doesn't come back up. After some investigation it appears to have been introduced with this pr: #11691

Essentially if the first promise wins then it resolves and await this.startApiServer() is called. The problem here is the second promise still executes so after 2 seconds it still kills the server anyways.

Running the following code in chrome dev tools console will demonstrate the issue:

const promise1 = new Promise((resolve) => {
  setTimeout(() => {
    console.log('Promise 1 resolved');
    resolve('First');
  }, 100);
});

const promise2 = new Promise((resolve) => {
  setTimeout(() => {
    console.log('Promise 2 resolved');
    resolve('Second');
  }, 200);
});

Promise.race([promise1, promise2]).then((value) => {
  console.log('Race settled with:', value);
});

Output is:
Promise 1 resolved
Race settled with: First
Promise 2 resolved

How do we reproduce the bug?

Make a change in some code on the api side and save so the server restarts

What's your environment? (If it applies)

No response

Are you interested in working on this?

  • I'm interested in working on this
@o0charlie0o o0charlie0o added the bug/needs-info More information is needed for reproduction label Nov 15, 2024
@s98berg
Copy link

s98berg commented Nov 20, 2024

After upgrading to 8.4.1 the same thing happens in my project that if I edit in the api the server shuts down and doesn't start again. I use vscode on mac. Really glad I found the bug report here, because I've spent hours debugging.

@cadlagtrader
Copy link

Same thing happening to me on 8.4.1 without editing any file.

It seems yarn rw dev api touch trustedDocumentSotore when starting and 8.4.1 fails to restart it

[change] /src/lib/trustedDocumentsStore.ts

@Lijwent
Copy link

Lijwent commented Dec 7, 2024

I have almost the same problem, the API comes back up but is still killed
api | 01:16:28 🌲 request completed 88ms
api | Building...
api | Took 747 ms
api | Shutting down API server.
api | 01:16:29 🌲 Starting a postgresql pool with 1 connections.
api | Debugger attached.
01:16:30 | 🌲 My custom log
api | API server did not exit within 2 seconds, forcefully closing it.

@Philzen
Copy link
Contributor

Philzen commented Dec 8, 2024

Oh yeah, i'm also seeing this after the upgrade to 8.4.1:

gen | File system change: change api/src/services/interviewPostprocessing/interviewPostprocessing.ts
gen | Modified Directory named module: api/src/services/interviewPostprocessing/interviewPostprocessing.ts 1 ms
api | Shutting down API server.
api | Took 2003 ms
api | Debugger listening on ws://127.0.0.1:18911/c114f28b-8f88-4c9d-a207-e4cd67a3ed2d
api | For help, see: https://nodejs.org/en/docs/inspector
api | 
api | 12:06:36 🌲 Configuring api side
api | Importing Server Functions... 
api | /auth 1268 ms
api | /livekit 1265 ms
api | ...Done importing in 1269 ms
api | API server did not exit within 2 seconds, forcefully closing it.
web | 12:07:02 PM [vite] http proxy error: /auth?method=getToken
web | Error: connect ECONNREFUSED :::8911
web |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1607:16)

But this doesn't happen deterministically, so it makes sense that this must be down to some sort of race condition (#11731 🚀 )

… seems like sort of a critical issue for the next patch release.

@Tobbe
Copy link
Member

Tobbe commented Dec 8, 2024

Yeah, this has been bugging me too. Thanks for the nudge here @Philzen 🙏

@lintfail
Copy link

Could we please have a patch release with this fix? Thanks in advance @Tobbe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants