diff options
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 67729ee39..2b0caff49 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) { @@ -495,11 +495,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, () => {}); @@ -515,7 +519,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() { @@ -630,7 +634,7 @@ signal?.addEventListener("abort", () => { clearInterval(dateInterval); - server.close(); + PromisePrototypeThen(server.close(), () => {}, () => {}); }, { once: true, }); @@ -664,7 +668,7 @@ ); } - const fastOp = prepareFastCalls(serverId); + const fastOp = prepareFastCalls(); let nextRequestSync = () => fastOp.nextRequest(); let getMethodSync = (token) => fastOp.getMethod(token); let respondFast = (token, response, shutdown) => @@ -684,8 +688,8 @@ } await SafePromiseAll([ - listenPromise, PromisePrototypeCatch(server.serve(), console.error), + serverPromise, ]); }; } |