fix(ext/flash): revert #16383 (graceful server startup/shutdown)#16610
fix(ext/flash): revert #16383 (graceful server startup/shutdown)#16610kt3k merged 3 commits intodenoland:mainfrom
Conversation
)" This reverts commit ff92feb.
|
I confirmed this revert makes the following test execution non-flaky in deno_std: (also confirmed main is flaky with the above command) |
magurotuna
left a comment
There was a problem hiding this comment.
LGTM, I'll take a look at it to see if there's a way to fix it.
|
I reduced the example of segfault to the below (no std involved): const ctl = new AbortController();
Deno.serve(() =>
new Promise((resolve) => {
resolve(new Response(new TextEncoder().encode("ok")));
ctl.abort();
}), {
signal: ctl.signal,
onListen() {
fetch("http://localhost:9000", { method: "POST" });
},
});Note:
(I'll add this as a test case). If I removed the line of |
|
I found that your snippet seems to be panicking for Deno v1.27.2 too. The difference is that on v1.27.2 it never segfaults (i.e. it always panics here, which is the same line as the panic log you pasted) regardless of the presence of |
|
Ah, sorry. The above seems panicking on a different problem 😓 Please use the below instead: const ctl = new AbortController();
Deno.serve(() =>
new Promise((resolve) => {
resolve(new Response(new TextEncoder().encode("ok")));
ctl.abort();
}), {
signal: ctl.signal,
async onListen({ port }) {
const a = await fetch(`http://localhost:${port}`, { method: "POST", body: "" });
await a.text();
},
});( This finishes with |
|
I suppose the cause is that now (after #16383) close operation is synchronous, causing the resources related to flash to be cleaned up immediately - in fact, if we update #[op]
async fn op_flash_close_server(state: Rc<RefCell<OpState>>, server_id: u32) {
let ctx = {
let op_state = &mut state.borrow_mut();
let flash_ctx = op_state.borrow_mut::<FlashContext>();
flash_ctx.servers.remove(&server_id).unwrap()
};
// Key: yield to the event loop once
deno_core::futures::pending!();
let _ = ctx.waker.wake();
}But I feel we could improve the code above further. I'll try to come up with that. |
|
@magurotuna Nice! But I'm landing this for now to unblock the std's CI. |
|
Yeah I agree with that. I'll continue working on another PR. |
…p/shutdown) (denoland#16610)" This reverts commit 336e96a.
#16383 made some of Node compat test cases flaky in deno_std (and when it fails it causes segfaults).
See denoland/std#2882 for details
cc @magurotuna
closes denoland/std#2882