Repository navigation
Ariadne L4: requests in single-threaded wasm don't stall the frame loop - #914
Merged
Merged
Conversation
In a browser build without threads the background pool's jobs run on the page's main thread,
so an http verb's kernel ran inside the frame pump and spun on emscripten_sleep(0) until the
reply came: nothing drew or took input for the whole request (100-300 ms, up to the 30 s
timeout).
- cvc::net: start(req[, policy], done) -> HttpTransfer (abort()), and http_starts_async().
The browser fetch backend issues an emscripten_fetch and returns; onsuccess/onerror deliver
the reply from the event loop. It reports a timeout as one, enforces the 64 MiB cap as the
body arrives, and aborts cleanly (no callback after abort). Elsewhere start() sends in place.
The policy check follows redirects hop by hop, as send(req, policy) does (shared next_hop).
- state_exec: async_work {kernel, start} and a register_async_fn overload. Where the call can
park, start() begins the work and the call is an external one with the registration's
timeout and charging; the work settles and posts it. async_call::on_cancel(stop) is how a
kill, a timeout or the host's shutdown stops it. Elsewhere the kernel runs as before.
- The net verbs (http-get, http-request) return an async_work when the transport starts
requests without blocking: credentials go in and captures come out in C++ around the
started request (perform split into prepare/complete). fetch of an http(s) URI uses the
http handler's new non-blocking form (register_uri_async_handler / resolve_async); a host's
own handler for the scheme drops it.
- AppRuntime::idle() counts the scheduler's calls in flight (started ones included), and
settle() yields to the browser's event loop in wasm, so ari snapshot waits for the reply.
Tests: AsyncCalls started-call cases (park, timed await slices, errors, kill, timeout,
shutdown, kernel fallback), NetStart (in place, later, policy hop by hop, abort),
AriadneNetL4 (frames go on while a program is parked on a request, await slices, teardown
aborts, credentials and capture on the started path, policy refusal, fetch). CI: the wasm
ari's node job runs tests/l4_frames.ari against a 1 s endpoint and fails unless frames ran
while the request was out (218 here; 0 with the blocking path).
Docs: ARIADNE.md 10.2, STATE_EXEC_EXCEPTIONS.md 3.12.
Owner
Author
|
Local native ctest on this branch (Linux GCC, Release, Ninja; filter |
This was referenced Oct 30, 2026
Merged
transfix
added a commit
to cy-pca/cypkg
that referenced
this pull request
Oct 30, 2026
…th a token or a browser (#6) * Snappier search: facets only for a new query, prefetched pages, a progress bar Next was slow because every page asked cvcpkg.org for facets, which makes it count every match: 1.2 s for page 2 of everything and 2.4 s for page 2 of zlib, against 0.2 s and 0.4 s without. Now only a new query or filter asks for facets (the honest package count); paging reuses that count. After showing a page the search module prefetches the next one in the background and keeps the page it left, so Next and Prev are answered with no request. Requests wait in 50 ms slices (http-get-async and await with a timeout), and between slices the module draws an indeterminate progress bar at the bottom of its view; the package module does too. lib.ari gains search-key, body-text and progress-bar, and search-query takes facets. The fixture logs its requests (/_requests) and answers a slow: name after a second. Module tests show a new query asks for facets and paging doesn't, Next and Prev make no request, and the bar draws during a slow request and clears after; with prefetch disabled they fail. * wip: windows * Menu bar and windows: builders, builds, activity, account; API-token sign-in A View menu opens a window per page the registry's site has: Builders, Builds (by status, paged), Activity and Account, beside Search. Each is a module in share/cypkg/, started when its window first opens, refreshing about every 10 s while open (idle-wait answers a click at once), with a progress bar at its bottom. Signing in: bin/cypkg --token-env VAR hands a cvctok_ token to ari (--credential-env, bound to the registry by a policy file for the run). main.ari asks the host (has? works only at the top level) and hands auth.* to the modules through a hole; every request then sends the token. Account shows whoami and signs out; a refused token is dropped. Browser sign-in (device pairing) waits on sha256-hex and random-token in libcvc. net.ari holds fetch, now shared by every module, so lib.ari stays pure. --progress off makes plain blocking requests, for a browser ari without transfix/libcvc#914, which CI's browser build now merges. The fixture serves builders, builds, activity and whoami; tests cover each module, the account signed in and out, each window's frame, and opening Builders from the View menu in FTXUI and tvision. * Sign in with a browser: device pairing, remembered between runs Account > Sign in with a browser runs cvcpkg's device pairing, its OIDC route for a terminal: a random verifier (random-token), its SHA-256 sent to /v1/auth/device, the code and an absolute approval URL shown, and a poll of /v1/auth/device/token at the server's interval (slow_down honoured) with capture_auth taking the access and refresh tokens into the host. Cancel stops it; a denied or expired code says so. main.ari re-asks the host once a token is captured. Sign out revokes a paired session on the server before forgetting it. bin/cypkg keeps the sign-in in ari's credential store (--credential-store cypkg, 0600) unless --no-remember. Pairing needs sha256-hex and random-token (transfix/libcvc#911); CI now merges #911 and #912, and the resolver keeps both sides of docs and test conflicts between open PRs. The fixture plays the pairing endpoints, with /_approve standing in for a person at /link; pairing_test.ari covers approve, revoke, deny, cancel. * CI: read ari's outputs before grepping them, so grep -q can't SIGPIPE the writer
This was referenced Oct 31, 2026
transfix
pushed a commit
that referenced
this pull request
Oct 31, 2026
…ded wasm (on #914) With #914's cvc::net::start, the image cache in a browser build without threads starts a picture's http(s) request (host_get_start: the policy and auth: on host_get's terms, prepared and completed around cvc::net::start; else the http handler's resolve_async) and decodes the reply when the browser hands it over, between frames. host_get_start is host_get, blocking, where the transport does not start requests.
This was referenced Oct 31, 2026
Ariadne: video:/audio: in the browser pages through <video>/<audio> (media M6, stacked on #935)
#936
Merged
transfix
pushed a commit
that referenced
this pull request
Nov 6, 2026
…ter, without #925) This rebuilds the branch on master, which now has #923, #914 and #926, and drops the #925 merge: #925 (feat/ariadne-ws-nonblocking) is still open and fails its own AriadneNetL4.WebSocket* tests on macOS, which also failed this PR. This commit's tree is master plus the feature alone; its first parent keeps the branch's earlier history, so nothing is rewritten. A browser's WebSocket can send no request headers, but it can offer subprotocols, so a credential there is the one handshake auth a document in the wasm page can use. ws-open takes two new options: - "protocols": a list of subprotocols to offer (Sec-WebSocket-Protocol), each an HTTP token. - "auth_protocol": (dict "credential" NAME ["prefix" P] ["encoding" "raw"| "base64url"]) offers the host's token for NAME, fetched for the URL's origin as for auth, as one more subprotocol: P then the token, or its unpadded base64url (a token68's '/' or '=' can't be in a subprotocol), as Kubernetes does with "base64url.bearer.authorization.k8s.io.". cvc::net: WsOptions::protocols is sent natively as a Sec-WebSocket-Protocol line and in the browser through createAttributes.protocols. Both fail the connect unless the server picks one of the offered subprotocols, as browsers do (RFC 6455 4.1; natively from the 101's headers, which libcurl files under CURLH_1XX). An invalid or repeated subprotocol is refused, with no error quoting one, and the joined strings are wiped. ws_valid_protocol is public for the option checks. The token is wiped after the connect, and errors are redacted of it and of its base64url spelling. The connection records the name, so ws-recv and ws-poll blank either spelling if the server echoes it. Tests: NetWsClient covers offering, a server that picks none or another subprotocol, and invalid subprotocols. AriadneNetHost. WsOpenOffersTheHostsTokenAsASubprotocol checks the handshake line, the redacted echo, a raw token with '/' that is refused without connecting, and that no state node holds the token. LocalWsServer can pick a subprotocol. Spec: docs/ARIADNE.md section 10.5.
transfix
added a commit
that referenced
this pull request
Nov 6, 2026
* Ariadne L4: requests in single-threaded wasm don't stall the frame loop
In a browser build without threads the background pool's jobs run on the page's main thread,
so an http verb's kernel ran inside the frame pump and spun on emscripten_sleep(0) until the
reply came: nothing drew or took input for the whole request (100-300 ms, up to the 30 s
timeout).
- cvc::net: start(req[, policy], done) -> HttpTransfer (abort()), and http_starts_async().
The browser fetch backend issues an emscripten_fetch and returns; onsuccess/onerror deliver
the reply from the event loop. It reports a timeout as one, enforces the 64 MiB cap as the
body arrives, and aborts cleanly (no callback after abort). Elsewhere start() sends in place.
The policy check follows redirects hop by hop, as send(req, policy) does (shared next_hop).
- state_exec: async_work {kernel, start} and a register_async_fn overload. Where the call can
park, start() begins the work and the call is an external one with the registration's
timeout and charging; the work settles and posts it. async_call::on_cancel(stop) is how a
kill, a timeout or the host's shutdown stops it. Elsewhere the kernel runs as before.
- The net verbs (http-get, http-request) return an async_work when the transport starts
requests without blocking: credentials go in and captures come out in C++ around the
started request (perform split into prepare/complete). fetch of an http(s) URI uses the
http handler's new non-blocking form (register_uri_async_handler / resolve_async); a host's
own handler for the scheme drops it.
- AppRuntime::idle() counts the scheduler's calls in flight (started ones included), and
settle() yields to the browser's event loop in wasm, so ari snapshot waits for the reply.
Tests: AsyncCalls started-call cases (park, timed await slices, errors, kill, timeout,
shutdown, kernel fallback), NetStart (in place, later, policy hop by hop, abort),
AriadneNetL4 (frames go on while a program is parked on a request, await slices, teardown
aborts, credentials and capture on the started path, policy refusal, fetch). CI: the wasm
ari's node job runs tests/l4_frames.ari against a 1 s endpoint and fails unless frames ran
while the request was out (218 here; 0 with the blocking path).
Docs: ARIADNE.md 10.2, STATE_EXEC_EXCEPTIONS.md 3.12.
* Ariadne: WebSocket client verbs (ws-open, ws-send, ws-poll, ws-recv, ws-close)
A document can follow a server that pushes changes instead of polling it.
cvc::net gets a WebSocket client (ws_client.h) with two backends: libcurl's
WebSocket API natively, so wss:// has the same TLS and proxy handling as
https://, and the browser's WebSocket under Emscripten. Messages arrive whole
in a queue; ws-poll takes what is there without waiting, for on_tick loops,
and ws-recv waits on the background pool. The host's policy checks a ws(s)
URL as its http(s) twin, and auth/headers/credential values work as for the
HTTP verbs (natively; a browser WebSocket sends no headers).
Documented in ARIADNE.md 10.5, with client tests against a Beast server and
verb tests in ariadne_runtime_test.
* ws client tests: a Beast close code is an enum; copy the handshakes before looping over them
* ws client: build on MSVC (windows.h's min macro broke std::min)
* Ariadne: ws-open and ws-recv don't stall the frame loop in single-threaded wasm
#923's browser WebSocket waited in loops on emscripten_sleep(10): WebWsConnection::wait_open
inside ws_connect (up to the 15 s connect timeout) and recv (up to ws-recv's seconds). Without
-pthread those kernels run on the pump thread, so ws-open and ws-recv froze the page, as http-get
did before #914. This moves them onto #914's path.
- cvc::net: ws_start(url, opts, done) and WsConnection::recv_async(timeout, done), plus
ws_starts_async() and a set_ws_connector seam (WsConnector), as set_http_client is for HTTP.
The browser backend in a build without threads answers from the WebSocket's own callbacks
(on_open / on_error / on_close / on_message) and emscripten_set_timeout timers; the returned
stop function abandons a connect (closing the socket, a connecting one too) or drops a wait.
Elsewhere both wait in place, as before.
- ws-open and ws-recv return a state_exec async_work (#914) when ws_starts_async(): the program
parks, frames go on, and the callbacks post the reply; a killed or timed-out call abandons its
connect or drops its wait (on_cancel). ws-open's checks, credentials and handle table are
shared by the kernel and the started path (build / prepare / finish_ws_open).
- WebWsConnection::close sends 1000 for a code a page may not send (WebSocket.close throws on
anything but 1000 and 3000-4999, the 1001 and 1013 this file uses included).
Tests: AriadneNetL4.WebSocketOpenAndRecvAreStartedWhileFramesGoOn and
ATornDownDocumentAbandonsItsConnectAndItsWait (a deferred connector and connection the test
answers between frames; forcing ws-open back to its kernel fails both). CI: the wasm ari's node
job runs tests/l4_ws.ari against tests/ws_probe_server.py (stdlib; a 1 s handshake, then a
message 1 s later) and fails unless 20 frames ran during each wait: 354 and 374 here, 0 and 0
with the blocking path.
Docs: ARIADNE.md 10.5.
* ws verbs: clang-format the changed lines
* ws client: close before queueing the oversized-message error
The reader queued the Error event and then closed, so a recv on another
thread could take the error while open() was still true; NetWsClient.
AnOversizedMessageIsAnError failed about one run in five. Closing first
matches the peer-close path, which clears open_ before it queues.
* Ariadne: ws-send carries a credential the host puts in
A browser's WebSocket can't send request headers, so a document in the wasm
page could only authenticate a live feed by holding the token and sending it
in a message, and documents never see tokens. Now (ws-send H MESSAGE) sends a
dict or list as JSON (json-encode, compact), and a (dict "credential" NAME)
anywhere in it goes out as the host's token for NAME, a JSON string:
(ws-send h (dict "type" "hello" "token" (dict "credential" "txwtf")))
- The token is fetched for the origin the connection was opened and checked
as (its URL's http(s) twin, now kept in the handle table), so credential
bindings apply as for HTTP. It is put in on the host just before the send,
with room reserved so no replace leaves a copy in a freed buffer, then
wiped; a send error is redacted.
- A name with no token at that origin, or a credential value on a host that
keeps no credentials, is an error and sends nothing.
- Each connection remembers the credentials it has sent (handshake auth and
header values too), and ws-recv / ws-poll blank them to [redacted] in what
they return, as perform() does for an HTTP reply, should the server echo one.
- A string message is sent as it is, as before.
Tests: AriadneNetHost.WsSendPutsInTheHostsTokenThatNoValueHolds checks, against
LocalWsServer, that the server gets the substituted token while no state node,
error or warning holds it, that an echo comes back redacted and that a missing
credential sends nothing; the round-trip test checks plain JSON and a host
without credentials. Spec: docs/ARIADNE.md section 10.5.
Merges master for #883's builtin_json_encode.
* Ariadne: ws-open offers subprotocols, and a credential as one
A browser's WebSocket can send no request headers, but it can offer
subprotocols, so a credential there is the one handshake auth a document in the
wasm page can use. ws-open takes two new options:
- "protocols": a list of subprotocols to offer (Sec-WebSocket-Protocol), each an
HTTP token.
- "auth_protocol": (dict "credential" NAME ["prefix" P] ["encoding" "raw"|
"base64url"]) offers the host's token for NAME, fetched for the URL's origin as
for auth, as one more subprotocol: P then the token, or its unpadded base64url
(a token68's '/' or '=' can't be in a subprotocol), as Kubernetes does with
"base64url.bearer.authorization.k8s.io.".
cvc::net: WsOptions::protocols is sent natively as a Sec-WebSocket-Protocol line
and in the browser through createAttributes.protocols, in both the blocking and
the started connect. Both fail the connect unless the server picks one of the
offered subprotocols, as browsers do (RFC 6455 4.1; natively from the 101's
headers, which libcurl files under CURLH_1XX). An invalid or repeated
subprotocol is refused, with no error quoting one, and the joined strings are
wiped. ws_valid_protocol is public for the option checks.
The token is wiped after the connect, and errors are redacted of it and of its
base64url spelling. The connection records the name, so ws-recv and ws-poll
blank either spelling if the server echoes it.
Tests: NetWsClient covers offering, a server that picks none or another
subprotocol, and invalid subprotocols. AriadneNetHost.
WsOpenOffersTheHostsTokenAsASubprotocol checks the handshake line, the
redacted echo, a raw token with '/' that is refused without connecting, and that
no state node holds the token. LocalWsServer can pick a subprotocol. The wasm
file compiles with em++, with and without threads. Spec: docs/ARIADNE.md
section 10.5.
---------
Co-authored-by: nicotina-ci <[email protected]>
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
…eaded wasm (#925) * Ariadne L4: requests in single-threaded wasm don't stall the frame loop In a browser build without threads the background pool's jobs run on the page's main thread, so an http verb's kernel ran inside the frame pump and spun on emscripten_sleep(0) until the reply came: nothing drew or took input for the whole request (100-300 ms, up to the 30 s timeout). - cvc::net: start(req[, policy], done) -> HttpTransfer (abort()), and http_starts_async(). The browser fetch backend issues an emscripten_fetch and returns; onsuccess/onerror deliver the reply from the event loop. It reports a timeout as one, enforces the 64 MiB cap as the body arrives, and aborts cleanly (no callback after abort). Elsewhere start() sends in place. The policy check follows redirects hop by hop, as send(req, policy) does (shared next_hop). - state_exec: async_work {kernel, start} and a register_async_fn overload. Where the call can park, start() begins the work and the call is an external one with the registration's timeout and charging; the work settles and posts it. async_call::on_cancel(stop) is how a kill, a timeout or the host's shutdown stops it. Elsewhere the kernel runs as before. - The net verbs (http-get, http-request) return an async_work when the transport starts requests without blocking: credentials go in and captures come out in C++ around the started request (perform split into prepare/complete). fetch of an http(s) URI uses the http handler's new non-blocking form (register_uri_async_handler / resolve_async); a host's own handler for the scheme drops it. - AppRuntime::idle() counts the scheduler's calls in flight (started ones included), and settle() yields to the browser's event loop in wasm, so ari snapshot waits for the reply. Tests: AsyncCalls started-call cases (park, timed await slices, errors, kill, timeout, shutdown, kernel fallback), NetStart (in place, later, policy hop by hop, abort), AriadneNetL4 (frames go on while a program is parked on a request, await slices, teardown aborts, credentials and capture on the started path, policy refusal, fetch). CI: the wasm ari's node job runs tests/l4_frames.ari against a 1 s endpoint and fails unless frames ran while the request was out (218 here; 0 with the blocking path). Docs: ARIADNE.md 10.2, STATE_EXEC_EXCEPTIONS.md 3.12. * Ariadne: WebSocket client verbs (ws-open, ws-send, ws-poll, ws-recv, ws-close) A document can follow a server that pushes changes instead of polling it. cvc::net gets a WebSocket client (ws_client.h) with two backends: libcurl's WebSocket API natively, so wss:// has the same TLS and proxy handling as https://, and the browser's WebSocket under Emscripten. Messages arrive whole in a queue; ws-poll takes what is there without waiting, for on_tick loops, and ws-recv waits on the background pool. The host's policy checks a ws(s) URL as its http(s) twin, and auth/headers/credential values work as for the HTTP verbs (natively; a browser WebSocket sends no headers). Documented in ARIADNE.md 10.5, with client tests against a Beast server and verb tests in ariadne_runtime_test. * ws client tests: a Beast close code is an enum; copy the handshakes before looping over them * ws client: build on MSVC (windows.h's min macro broke std::min) * Ariadne: ws-open and ws-recv don't stall the frame loop in single-threaded wasm #923's browser WebSocket waited in loops on emscripten_sleep(10): WebWsConnection::wait_open inside ws_connect (up to the 15 s connect timeout) and recv (up to ws-recv's seconds). Without -pthread those kernels run on the pump thread, so ws-open and ws-recv froze the page, as http-get did before #914. This moves them onto #914's path. - cvc::net: ws_start(url, opts, done) and WsConnection::recv_async(timeout, done), plus ws_starts_async() and a set_ws_connector seam (WsConnector), as set_http_client is for HTTP. The browser backend in a build without threads answers from the WebSocket's own callbacks (on_open / on_error / on_close / on_message) and emscripten_set_timeout timers; the returned stop function abandons a connect (closing the socket, a connecting one too) or drops a wait. Elsewhere both wait in place, as before. - ws-open and ws-recv return a state_exec async_work (#914) when ws_starts_async(): the program parks, frames go on, and the callbacks post the reply; a killed or timed-out call abandons its connect or drops its wait (on_cancel). ws-open's checks, credentials and handle table are shared by the kernel and the started path (build / prepare / finish_ws_open). - WebWsConnection::close sends 1000 for a code a page may not send (WebSocket.close throws on anything but 1000 and 3000-4999, the 1001 and 1013 this file uses included). Tests: AriadneNetL4.WebSocketOpenAndRecvAreStartedWhileFramesGoOn and ATornDownDocumentAbandonsItsConnectAndItsWait (a deferred connector and connection the test answers between frames; forcing ws-open back to its kernel fails both). CI: the wasm ari's node job runs tests/l4_ws.ari against tests/ws_probe_server.py (stdlib; a 1 s handshake, then a message 1 s later) and fails unless 20 frames ran during each wait: 354 and 374 here, 0 and 0 with the blocking path. Docs: ARIADNE.md 10.5. * ws verbs: clang-format the changed lines * tests: keep the async_task.h include line as master has it * ws client: an oversized message closes the connection before its error is queued The curl backend's reader pushed the Error event and then called close(1009), which clears open(). A program (or NetWsClient.AnOversizedMessageIsAnError) that took the error at once could still see open() true: the Windows recipe lane failed on it. Close first, as the peer-close paths already do, so open() is false from the last event on (docs/ARIADNE.md 10.5). * ci: the WebSocket connector cell on the writable-data scan's allowlist set_ws_connector's process-wide connector (connector_cell, connector_mutex) is the WebSocket twin of set_http_client's client_cell/client_mutex, which the allowlist already carries: a test or host swaps the transport for the whole process, as it does for HTTP. * ws-open's transport comes in the NetAccess, not a process-wide connector set_ws_connector kept one WebSocket connector for the whole process (a function-static cell and its mutex), the kind of state P0a removes; this branch had put the cell on the writable-data scan's allowlist. It is gone: - NetAccess::ws is the transport the ws-* verbs connect through (a test's that it answers between frames, or a host's own); null is the compiled backend. NetHostConfig::ws hands one to enable_net. - cvc::net::WsConnector stays, as the interface such a transport implements; ws_connect, ws_start and ws_starts_async are the compiled backend only, and have_ws_backend() is again what the build has. - The verbs are registered when the access has a transport or the build has a backend, so the AriadneNetL4 WebSocket tests run where libcurl has none. - The allowlist is master's again (cvc 451). --------- Co-authored-by: nicotina-ci <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roadmap item L4 (cy-pca/nicotina docs/ROADMAP.md; cy-pca/cypkg docs/ROADMAP.md L4). In the single-threaded wasm pages (
ari.html, arigl's page), every request stalled the frame loop. Now the page keeps drawing and taking input while a request is out.The problem
Without
-pthread, the background pool and the async lanes are forced tolane_mode::deferred, so an http verb's kernel ran on the pump thread.cvc::net::HttpClient::send()is synchronous: in wasm it issues anemscripten_fetchand spins onemscripten_sleep(0)until the reply. While it spun, the frame that called it was on the stack, so nothing drew and no input was taken. That lasted 100–300 ms per request, up to the 30 s timeout. Native and wasm-mt were fine: there the kernel blocks a pool worker.What changes
send().start(req[, policy], done)returns anHttpTransferwithabort();http_starts_async()says whether the client answers later.onsuccess/onerrordeliver the reply from the event loop.onprogress). Afterabort()no callback runs, and Fetch.js releases its keepalive itself.send(req, policy)does; both sharenext_hop.async_work {kernel, start}(a newregister_async_fnoverload).-asyncfuture,startbegins the work. The call is an external call with the registration's timeout and I/O charging, and the work settles it and posts it (settle+host.finish).async_call::on_cancel(stop)is how a kill or reap, the call's timeout, or the host's shutdown stops it.http-getandhttp-requestreturn anasync_workwhenhttp_starts_async().perform()is split intoprepare/complete. Credentials (auth, credential values) go in, andcapture_authand echo-scrubbing come out, in C++ around the started request. No token reaches avalue_t.fetchof anhttp(s)URI uses the http handler's new non-blocking form (register_uri_async_handler/resolve_async). A host that registers its ownhttphandler drops that form, so its handler is called as before.AppRuntime:idle()counts the scheduler's calls in flight, started ones included. In wasm,settle()yields withemscripten_sleep, soari snapshotwaits for the reply there.The DSL contract is the same on native, wasm and wasm-mt: the reply dict, the policy,
auth/capture_auth/ credential values, kill → abort, the timeout and the cap.Still blocking, and why (documented in ARIADNE.md 10.2)
httpsimport:/load:while the document loads, and a scene'ssource:mesh or texture URL when the scene is realized (resolve_to_file). These still use the blockingsend(). The browser pages fetch relative imports themselves (arigl-web + ari page: stock browser hosts that run .ari documents by URL; arigl and arigl-web packages #887).Making scene realization async is a separate piece.
Tests
state_exec_async_calls_test: 7 new cases. A started call parks until its work answers. A future awaited in 10 ms slices times out repeatedly while the work goes on (cypkg's progress loop). The work's error raises at the call, and so does a throwingstart. A kill, a registration timeout and a host shutdown each run the cancel hook. Where nothing can park, the kernel runs. 54/54.net_policy_test:NetStart, 4 cases: answered in place, answered later, policy checked hop by hop (Authorization dropped cross-origin, refused hop never requested),abort()mid-chain. 27/27.ariadne_runtime_test:AriadneNetL4, 6 cases, with a deferred transport the test answers between frames as the page's event loop would:http-get, and the reply then resumes it;(await f 0.02)slices;capture_auth, thenauth:, on the started path, with no token in state;fetchof an http URI is started, while a host's own handler still runs in place.Ariadne|ari|Net|Uri|AsyncCalls|StateExec…, 990 tests): see the comment below for the final count.aribuilt as CI builds it (minus ImageMagick).net_probe.aristill passes: sign-in, refresh,auth, refusal,[redacted].tests/l4_frames.ariagainst a 1 s/v1/slow: 218 frames ran while the request was out; with the blocking path forced, 0.ari terminal backend (wasm, node)job gets this as a step and fails under 20.ari.htmlfrom that build, served with a 3 s endpoint on the same origin, in Chrome. The frame counter kept rising (18 → 24 → 69) while the request was out, and the reply recorded 57 frames (the page's 20 fps).Coordination
cy-pca/cypkg ("Cypkg project setup" session): before starting, I asked it what it had done or planned about blocking HTTP in wasm. Its open work is Snappier search: facets only for a new query, prefetched pages, a progress bar cy-pca/cypkg#5 (snappy):
http-get-async+(await f 0.05)slices and a progress bar drawn by the document. That PR hands the wasm stall to "the libcvc session working on async fetch in single-threaded wasm (L4)", with no change needed on cypkg's side. No libcvc branch of its touches these files. After this opened, it confirmed it has no libcvc work on blocking HTTP, emscripten_fetch or emscripten_sleep, and agreed the split: cypkg owns the document side, this PR owns libcvc's transport and scheduler. Contracts it relies on, all kept here:(await f secs)raisesTimeoutErrorand a later await still returns the value; the reply dict's shape; async calls from aload:ed module'son_tick(Ariadne: a load:ed module's on_tick: runs at its mount #904). Its slice loop is covered byAStartedCallsFutureAwaitsWithATimeoutAsTheWorkGoesOnandAriadneNetL4.AwaitSlicesRunWhileTheRequestIsOut.L7 (generic OIDC sign-in, another session): told about
cvc::net::start/async_work, so host-side OIDC requests don't use the blockingsend()on the frame thread. Its document-level requests through the verbs need nothing.Spinner widget: a separate PR follows.
cypkg's browser test against this PR (reported by the Cypkg session: master + state_exec: json-parse, json-encode and state-set-tree, so documents can read REST replies #883, Ariadne: (quit code), assert and
ari test#896, Ariadne: functions: shared with a document's programs and granted to its modules #900, Ariadne: a load:ed module's on_tick: runs at its mount #904 and this PR; single-threaded ari.html; headless Chrome):(await f 0.05)loop finishes in the browser;http-getincluded), so it predates this PR. It is being tracked separately and is not fixed here.