fix(ext/flash): graceful server startup/shutdown with unsettled promises in mind#16616
fix(ext/flash): graceful server startup/shutdown with unsettled promises in mind#16616bartlomieju merged 30 commits intodenoland:mainfrom
Conversation
…p/shutdown) (denoland#16610)" This reverts commit 336e96a.
a189ab9 to
ecfc696
Compare
| // Now the flash thread is about to finish, but there may be some unsettled | ||
| // promises in the main thread that will use the socket. To make the socket | ||
| // alive longer enough, we move its ownership to the main thread. | ||
| for (tok, socket) in sockets { | ||
| if let Some(sender) = socket_senders.remove(&tok) { | ||
| // Do nothing if the receiver has already been dropped. | ||
| _ = sender.send(socket); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This is the key idea; to prevent sockets from being released when the flash server finishes, transmit them to each ServerContext. This ensures that unsettled promises that outlive the flash thread can use sockets later.
| pub parse_done: ParseStatus, | ||
| pub buffer: UnsafeCell<Vec<u8>>, | ||
| pub read_lock: Arc<Mutex<()>>, | ||
| pub _pinned: PhantomPinned, |
There was a problem hiding this comment.
This is not directly related to this PR, but I feel this field is a must so we can make sure that Stream is not moved when it's Pinned.
| let port: number; | ||
|
|
||
| const server = Deno.serve({ | ||
| handler: (_req) => new Response("ok"), | ||
| hostname: "localhost", | ||
| port: 4501, | ||
| signal: ac.signal, | ||
| onListen: onListen(listeningPromise), | ||
| onError: createOnErrorCb(ac), | ||
| port: 0, | ||
| signal: ac1.signal, | ||
| onListen: (addr) => { | ||
| port = addr.port; | ||
| listeningPromise.resolve(); | ||
| }, | ||
| onError: createOnErrorCb(ac1), |
There was a problem hiding this comment.
Using port number 4501 makes CI really flaky. On my local ubuntu machine I was not able to see this flakiness though.
kt3k
left a comment
There was a problem hiding this comment.
Confirmed this change doesn't cause the issue denoland/std#2882 anymore
LGTM
|
I found some test failures with net-related compat test cases. If I run the following command in std, there seem many test failures: Look like this has a different problem? 🤔 Most failures show this error message: |
|
ugh... Will dig into that. Minimum reproducible code would be appreciated. |
|
What I noticed so far is the |
|
Super interesting, weird fact: if we build deno with |
|
Really flaky 🤷 |
|
Yeah, I'm not able to repeat this flakiness locally either :/ |
|
Hmm, from my quick observation, there seems to be three patterns of test failures.
Among these, only 3 is specific to this PR - other 2 failures happen on the main branch too. |
|
d7ca7eb fell into the case 1 (macos timeout) |
I also confirmed |
|
67aac4a fell into the case 3 |
|
@bartlomieju What do you think about the flakiness we are facing? I ran this failing test case locally line 10 times and saw no failure. Would it be okay to disable this test for the time being? |
Yes, I think that's reasonable |
|
@bartlomieju PTAL before actually getting it landed just in case. |
…ed promises in mind (denoland#16616)" This reverts commit fd023cf.
#16839) …ed promises in mind (#16616)" This reverts commit fd023cf. There are reports saying that Vite is often hanging in 1.28.2 and this is the only PR that changed something with HTTP server. I think we should hold off on trying to fix this and instead focus on #16787 CC @magurotuna
…2950) This reverts commit 5f5413d. This change was made in response to denoland/deno#16616. However, that change was reverted in denoland/deno#16839 due to it breaking Vite. Let's revert it here as well.
#16839) …ed promises in mind (#16616)" This reverts commit fd023cf. There are reports saying that Vite is often hanging in 1.28.2 and this is the only PR that changed something with HTTP server. I think we should hold off on trying to fix this and instead focus on #16787 CC @magurotuna
This PR resets the revert commit made by #16610, bringing back #16383 which attempts to fix the issue happening when we use the flash server with
--watchoption enabled.Also, some code changes are made to pass the regression test added in #16610. These changes can be seen here: https://github.com/denoland/deno/compare/0f31256..99f9670
Closes #16699