diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2022-11-13 17:35:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-13 17:35:28 +0900 |
commit | 336e96a114555994b9e996c705c00d23b735d9d6 (patch) | |
tree | edb23c4d39bad2af2dd13ebc537aea2e315c799d /ext/flash/01_http.js | |
parent | 88643aa4780d1099d81ea5b971278d04dd5d3dd2 (diff) |
fix(ext/flash): revert #16383 (graceful server startup/shutdown) (#16610)
#16383 made some of Node compat test cases flaky in deno_std (and when
it fails it causes segfaults).
See https://github.com/denoland/deno_std/issues/2882 for details
Diffstat (limited to 'ext/flash/01_http.js')
-rw-r--r-- | ext/flash/01_http.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index 8eed6047e..7a6b9bc47 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -188,8 +188,8 @@ return str; } - function prepareFastCalls(serverId) { - return core.ops.op_flash_make_request(serverId); + function prepareFastCalls() { + return core.ops.op_flash_make_request(); } function hostnameForDisplay(hostname) { @@ -482,11 +482,15 @@ const serverId = opFn(listenOpts); const serverPromise = core.opAsync("op_flash_drive_server", serverId); - const listenPromise = PromisePrototypeThen( - core.opAsync("op_flash_wait_for_listening", serverId), - (port) => { - onListen({ hostname: listenOpts.hostname, port }); - }, + + PromisePrototypeCatch( + PromisePrototypeThen( + core.opAsync("op_flash_wait_for_listening", serverId), + (port) => { + onListen({ hostname: listenOpts.hostname, port }); + }, + ), + () => {}, ); const finishedPromise = PromisePrototypeCatch(serverPromise, () => {}); @@ -502,7 +506,7 @@ return; } server.closed = true; - core.ops.op_flash_close_server(serverId); + await core.opAsync("op_flash_close_server", serverId); await server.finished; }, async serve() { @@ -614,7 +618,7 @@ signal?.addEventListener("abort", () => { clearInterval(dateInterval); - server.close(); + PromisePrototypeThen(server.close(), () => {}, () => {}); }, { once: true, }); @@ -629,7 +633,7 @@ ); } - const fastOp = prepareFastCalls(serverId); + const fastOp = prepareFastCalls(); let nextRequestSync = () => fastOp.nextRequest(); let getMethodSync = (token) => fastOp.getMethod(token); let respondFast = (token, response, shutdown) => @@ -649,8 +653,8 @@ } await SafePromiseAll([ - listenPromise, PromisePrototypeCatch(server.serve(), console.error), + serverPromise, ]); }; } |