diff options
Diffstat (limited to 'ext/flash/01_http.js')
-rw-r--r-- | ext/flash/01_http.js | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index 7a6b9bc47..8eed6047e 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -188,8 +188,8 @@ return str; } - function prepareFastCalls() { - return core.ops.op_flash_make_request(); + function prepareFastCalls(serverId) { + return core.ops.op_flash_make_request(serverId); } function hostnameForDisplay(hostname) { @@ -482,15 +482,11 @@ const serverId = opFn(listenOpts); const serverPromise = core.opAsync("op_flash_drive_server", serverId); - - PromisePrototypeCatch( - PromisePrototypeThen( - core.opAsync("op_flash_wait_for_listening", serverId), - (port) => { - onListen({ hostname: listenOpts.hostname, port }); - }, - ), - () => {}, + const listenPromise = PromisePrototypeThen( + core.opAsync("op_flash_wait_for_listening", serverId), + (port) => { + onListen({ hostname: listenOpts.hostname, port }); + }, ); const finishedPromise = PromisePrototypeCatch(serverPromise, () => {}); @@ -506,7 +502,7 @@ return; } server.closed = true; - await core.opAsync("op_flash_close_server", serverId); + core.ops.op_flash_close_server(serverId); await server.finished; }, async serve() { @@ -618,7 +614,7 @@ signal?.addEventListener("abort", () => { clearInterval(dateInterval); - PromisePrototypeThen(server.close(), () => {}, () => {}); + server.close(); }, { once: true, }); @@ -633,7 +629,7 @@ ); } - const fastOp = prepareFastCalls(); + const fastOp = prepareFastCalls(serverId); let nextRequestSync = () => fastOp.nextRequest(); let getMethodSync = (token) => fastOp.getMethod(token); let respondFast = (token, response, shutdown) => @@ -653,8 +649,8 @@ } await SafePromiseAll([ + listenPromise, PromisePrototypeCatch(server.serve(), console.error), - serverPromise, ]); }; } |