Unreleased [Not released yet]
Part 3 of 15. Previous part
Added (72)
- Onion lints for an app with
scripts = false. They are two more rules (42 in all) and a new lint group,onion.onion-fetchis an error. It finds what the browser loads from another host:src,srcset,poster,<object data>,<link href>(stylesheet, preload, icon, manifest, preconnect), CSSurl()and@import(in a.cssfile, a<style>block and astyleattribute) and asrc/fonts.txtline withcdnor a URL. A URL that starts with//,http:orhttps:in any case counts as another host. A relative,data:, hole or<a href>URL, a comment, Markdown code and a component call are not found.onion-formis a warning. It finds a form that posts to another host. The build reads the shell, templates, Markdown pages and the CSS insrcandstatic, so a request pays nothing. Set a level, or the grouponion, in[package.metadata.wisp.lint]. Browser::scripts(false)ofwisp::testturns JavaScript off in the page of a browser test, with the DevTools commandEmulation.setScriptExecutionDisabled.scripts(true)turns it on again. The testnojs/tests/browser.rsdrives the pages, the forms and the redirects ofexamples/nojsthis way, and the gate runs it where a Chrome or Edge is installed. See In a Browser.wisp build --target extension [--out dist]writes a Chrome extension folder (Manifest V3). It is the static export. Wisp's own files go underwisp/, not_app/, because Chrome refuses a file or folder name that starts with_. Each<a href>to a page becomes<route>/index.html. The build writes no_headers,.nojekyllor404.html. The app writesmanifest.jsonin its folder. The build copies it and checks thatmanifest_versionis 3 and that each path it names is a file of the output. A route with actions, endpoints or a guard fails the build. An inline script, anon*attribute or ajavascript:URL inhref,src,actionorformactionin a page of the folder fails the build too, because the CSP of Manifest V3 blocks inline code.wisp new --template extensionandexamples/extensiongive a popup, an options page and a background worker. The gate stepextensionloads the folder in Chrome (WISP_CHROME). Checked only on Chrome for Testing 127.0.6533.88. See Browser Extension.- A manual start of the release workflow (
workflow_dispatch) on a branch runs only theverifyjob, without the tag steps. The publish jobs run only on a tag refrefs/tags/v*.
Changed (73)
- Jobs: the docs say what holds on a shared store. A job runs at least once. On a store shared by several servers, two servers can claim and run one job at the same time. Claims can race inside one poll window, or a lease can lapse. Make a job handler safe to run twice (use an idempotency key). Before, the docs said that no two servers run a job at once.
WISP_STORE=deno-kvno longer keeps saved tables. Wisp does not check row versions on Deno KV, so it cannot keep ids unique and stop old copies there. The app does not start: it logswisp: WISP_STORE: the store answered: WISP_STORE=deno-kv cannot keep saved tables: ...and answers each request with a 500. Used1:BINDINGor alibsql://address.wisp::kvandwisp::blobson Deno KV do not change.<form guard>in a page fails an edge build (wasm32: Cloudflare, Pages, Deno, Vercel, Netlify, Node and Bun hosts) with the file and line of the form.wisp check --target <host>fails on it too, for every host butlambda. Before, the build passed and each guarded post got a 501<form guard>needs the native server. The guard uses each token once, and each edge instance keeps its own list of used tokens, so a replay to another instance would go through. The release binary and Docker keep it.<form guard>in a page and<form once>in a page or layout fail the build for each--targethost (Cloudflare, Pages, Deno, Vercel, Netlify, Node, Bun and Lambda) and eachwasm32build, with the file and line of the form and the host.wisp check --target <host>fails on them too. Before, an edge build passed, each guarded post got a 501<form guard>needs the native server, and the edge build ignoredonce. Lambda kept both. Each form uses each token once, and each instance of the app keeps its own list of used tokens, so a replay to another instance would pass. The release binary and Docker keep both.- A WebSocket route fails
wisp build --targetandwisp check --targetfor Vercel and Netlify, with onefile:linefor each route. Before, the build warned, and the route answered 501. wisp check --target <host>shows the warnings ofwisp build --target <host>for code that WebAssembly cannot run (std::fs,std::thread,tokio::spawn,reqwestand the like).- The
h2feature encodes the head of an answer once, as HPACK, where the handler runs. Before, it copied each header name and value, made a list of references and encoded the head a second time. Instructions per request on one h2c connection:GET /36863 to 30306,HEAD /36846 to 29999, a JSONGET31635 to 26951,POST /tasks(201) 56741 to 51247. HTTP/1 does not change.GET /gave 13418.3 to 13419.4 on base and 13419.3 with the change. Two no-op probe builds of base gave 13418.3 to 13420.4.POST /tasksgave 32663.4 to 32758.6 on base and 32659.1 to 32659.2 with the change. The probes gave 32757.6 to 32850.5. A probe adds, in a cold file, a static or a function that no code calls. The HTTP/1 client sends each request on one keep-alive connection. Method: callgrind on a release build oftests/appwith--features h2in WSL,WISP_THREADS=1,WISP_IO=epoll. A figure is (Ir of 1000 requests - Ir of 1 request) / 999, from 2 runs of the change and 4 runs of base. The runs of base forPOST /tasksgave 56741 or 56836. Wisp 755d7a5e6 on 9e46e3e6e. - A
#[remote(prerender)]input past 2^53, up or down, fails the build with a new error text: "the number is not an integer within +-2^53". - The workflow header and the console line of
wisp deploy initnow read "It reads these secrets and variables: {secrets}." Before, they read "Secrets: {secrets}." The list holds variables too, not only secrets. wisp deploy initwith no host names two groups. The first line isWorkflow hosts (GitHub Actions): cloudflare-pages, cloudflare, deno, vercel, netlify, lambda, pages (GitHub Pages).The second line isConfig hosts: fly, render, railway, cloud-run (config and Dockerfile), docker [--onion], tor [--unix].Before, one list held all hosts and did not nametor.- The agent reference of an app is AGENTS.md and seven topic files in
wisp-ref/:content.md,nojs.md,browser.md,members.md,hooks.md,api.mdandcommands.md. AGENTS.md keeps Files, A page, Actions, Templates, Components, Endpoints and Gotchas, and an index that names each topic file and when to read it.wisp newandwisp update-docswrite the topic files. Each one ends with the end line of AGENTS.md, andwisp update-docskeeps the notes below it. It writes no other file ofwisp-ref/. It writes a pointer file (CLAUDE.md,.github/copilot-instructions.md,.cursor/rules/wisp.mdc) again only when it holds, byte for byte, the text that an olderwisp newwrote. That text calls AGENTS.md the whole reference.wisp upgrade --undoputs the topic files back too. llms-full.txt still holds all of the text, with a marker line before each topic file.wisp mcpgives a section of a topic file the title of that file, for examplewisp-ref/hooks.md > hooks.rs. In the repository the topic files are inllms/wisp-ref/. src/tests.rsneeds nomod tests;line. The build adds it as#[cfg(test)] mod testsat the crate root, souse crate::App;works in it. Whenmain.rsorlib.rsdeclaresmod tests, the build does not add it again. Withwisp::app!()inlib.rs, the library has the tests. Amain.rsthat also callswisp::app!()has them too. Amod x;in the added file issrc/x.rs, notsrc/tests/x.rs. So whensrc/tests.rsdeclares amod x;with no#[path]at its top level, the build does not add the module and shows a warning.wisp devandwisp checkshow it too. Withstrict = trueit is an error. A foldersrc/tests/of fixtures changes nothing. Then declaremod tests;in the crate root. Before, the build compiled asrc/tests.rsthat the crate root did not declare as a module of the app, also in release builds.- On Linux, a page or
Body::Bytesbody of 16 KiB or more goes in one send with its head: onesendmsgon epoll, oneOP_SENDMSGon io_uring. Before, the head and the body went in two sends. On/listof the native-rank app (34092 bytes, loopback, kernel 6.8.12), each response took 1tcp_sendmsgcall and 1 TCP segment, not 2. After a short send, the next send starts at the first byte that did not go. At start, io_uring checks that the kernel listsOP_SENDMSGand sends a test head and body with it. When either fails, the two sends stay, and the stderr line adds, no OP_SENDMSG (<cause>). prefixesof[package.metadata.wisp]takes only a string for each value, asprefixdoes. A bare value (a = b) is no value. Before, it read as the textb.- The Pages warning for
static/names the cause of each entry that reaches the worker: more than 99 entries, or a name over 100 characters. Only the first cause asks for folders. wisp devalways listens on the dev port and sends each request to the app, which listens on a loopback port of its own. A save that compiles starts the new app beside the old one. The front sends new requests to the new app once it answers. Then the old app stops after the requests it has (WISP_DRAIN). Before, a save stopped the app first, and requests during the restart failed. A new app that fails to start leaves the old one, and the terminal saysThe app of the build before still serves the requests.An app with saved tables opens its data folder only after the old app stopped, and the front holds new requests meanwhile. A held request waits at most 70 s, orWISP_DRAINand 23 s when that is longer. The front passesHost,Originand theX-Forwarded-*headers to the app as the client sent them, and names the client inx-wisp-peerwith a token of the run. A debug build takes that header only with the token and from a loopback peer, socx.peer()is the client. For the app, the front no longer addsX-Forwarded-*headers. A request for the app with no body keeps both connections open for the next request when the answer has a length. The front keeps at most 8 idle connections to the app. It keeps one only when no byte and no close wait on it after the end of the answer. Method names are case-sensitive, as in the app:headis notHEAD, so the front reads the body of its answer. Under--https, the front addsx-forwarded-proto: httpsfor a client that is not loopback or that sends a forwarding header. The front serves only aHostthat is an IP address,localhost, a*.localhostname or one inWISP_DEV_ORIGIN, else 403 (against DNS rebinding). This holds for the app, its WebSockets and event streams, and each proxy target. Init side effects (timers,wisp::spawnloops, jobs) run in both apps while they overlap, from the start of the new app until the old app stops. After the new app listens, that is up to 10 s for the health check, thenWISP_DRAINand 3 s. Underwisp devwith aHOSTother than loopback, the app signs with a key of its own process, not.wisp/secret(WISP_DEV_FRONT).[package.metadata.wisp.dev.proxy]rules apply on the next build, with no restart.- In
[package.metadata.wisp],scripts,public_env,strictandtypechecktake onlytrueorfalse. A quoted value such as"false"is an error with the same text for each key:Cargo.toml:scripts = "false"in [package.metadata.wisp]: write true or false (true is the default).version_polltakes only a number with no quotes. Before,scripts,public_envandversion_pollaccepted a quoted value, andstrictandtypecheckdid not. - A page of an
fsstore list can hold fewer thanlimitkeys while more exist, when the scan finds expired keys. Walk until the cursor isNone. Before, a page heldlimitkeys when that many live keys existed. wisp lspshows each parse error of a.wispfile, up to 100, not only the first. The parse continues at the next tag or block tag after an error, and the editor shows each block that is never closed. A later parse error may be a result of an earlier one.wisp buildandwisp checkstill stop at the first error, with the same text. Before, a parse error stopped the parse, so it was the only problem of the file.- The server reads
/proc/sys/fs/nr_open,/proc/self/cgroup,memory.maxand/proc/meminfoat start with onereadeach. Before,/proc/meminfotook 8 reads and each file took astatxand a second read. The io_uring start proof checks the large request against one 32881-byte pattern. Before, it built a copy of the request and a copy of the response (320 KiB). The proof checks the same bytes. Method: thewispapp ofbench/native-rankin WSL2 on 4 CPUs, start to first response. Page faults (perf stat -e page-faults, median of 5 runs, with thetasksetthat pins the CPUs): 451 before, 377 after. System calls (strace -f, one request): 638 before, 622 after. Cold start (60 alternating pairs): median 2.357 ms before, 2.309 ms after. The new start was faster in 37 pairs. The instructions of a warm request (bench/native-rank/ir.sh, 3 runs) stay the same: 2183.0 for/and 2381.0 for/json(the build of commit a67cafa97). - An io_uring worker lends 28 receive buffers at start, not 32. When they run out, it lends a quarter more, at least 16. After the start proof, the server gives free malloc pages back to the system (
malloc_trim, glibc only). The native-rankwispapp got 1000 keep-alive requests on/. Its VmRSS went from 4344 kB to 4288 kB (median of 20, 2 workers on CPUs 1-2, WSL 6.8). 256 keep-alive connections of 50 requests each had 0 errors. They had 201 receive rearms, from 193 (a counter in a test build, 2 runs). The work Ir per request does not change: 2183.0 on/and 2389.0 on/json(bench/native-rank/ir.sh, 3 runs, the build of commit 93335e0e6). wisp devcompiles the app crate with-C opt-level=0 -C codegen-units=16in every build that it runs (the first build and each save) when the profile hasopt-level0 or 1 (the scaffold has 1). A higheropt-levelstays as the app sets it. The dependencies keep the profile, andwisp buildand a cargo build are not changed. A save of a Rust edit shows in about 0.6 s, from about 1.5 s with the scaffold profile (opt-level = 1). Method: an app fromwisp newon Windows (4 CPUs, MSVC), 6 saves that change a function body. The "Rebuilt in" line ofwisp devshows 0.5 s after and 1.5 s before (a poll of/every 10 ms until the new text shows: median 0.6 s after, 1.5 s before). Onerustccall takes a median of 303 ms after and 1213 ms before, and the link takes 90 ms and 120 ms of that. The median time of a request to/in the dev server goes from 0.015 ms to 0.027 ms. Before, the app crate used theopt-levelof the profile.- On the epoll and io_uring drivers, a page body or an owned body (
Body::Bytes) of 16 KiB or more goes to the socket after the head with no copy into the write buffer. Only the last response of a read does this. A response before another one in the same read is copied as before. If the socket takes only part of the head on the epoll, the body is copied behind it. - The release workflow fails while the elan pin (
ELAN_COMMIT,ELAN_SHA256) is not set. Before, it skipped the proofs step. The CI workflow still skips it. Thecargo-denycheck in the release and scheduled workflows matches the version line exactly. Before,0.20.2also matched0.20.20. - The wasm build for Deno and Bun keeps error, redirect and WebSocket answers out of line, as the request-only build did. Deno compiles each wasm function on its first call. A table in memory skips its store check at start, so its code waits for its first use. The first
GET /of the bench app compiled 121355 body bytes before, and 108863 after (local Deno 2.9.7 trace,--trace-wasm-compilation-times). Cold start, user instructions (Paris b103, base 7733f3e04): Deno raw 143.00M -> 140.19M (-2.0%), Deno.serve 155.94M -> 153.21M (-1.8%), workerd 116.80M -> 114.83M (-1.7%). Bun and every warm request are flat. Native builds are the same. - The type of plain text is
text/plain;charset=UTF-8on every target (native, edge, static), nottext/plain; charset=utf-8. This coversResponse::text, the built-in error and health answers,robots.txtand.txtfiles. At load, the bridge checks ifnew Response(string)has this type (Deno and Node do, Bun does not). Where it does, the bridge sends a plain text 200 with no headers object. cx::decode(query and path parameters) checks UTF-8 without the lossy walk and keeps its decoded buffer, with no second copy. Deno raw/params/42?q=hello%20world&x=128.28k -> 27.94k, Deno.serve 40.47k -> 40.14k user instructions per request (Paris b54, 11 reps, disjoint, Wisp a76824924 on b45c83338).- Edge builds:
Cx::set_cookie_withkeeps one body for all value types, not one per type. The gate in the worktree measuredtests/edge-fullat 804978 bytes on 08b1505ea and 800353 bytes on 30cb4ae0f (-4625).tests/edge-sizechanged from 376120 to 376233 bytes (+113). - A
Passwordin a job or input_jsonis stored as its hash. A plain one is hashed when the job is pushed or stored. - Rows that
Sql::all/first,Kv::get_jsonand a job read are not checked against#[validate]. - Edge builds: an app without
Response::websocketlinks no WebSocket handshake code. The wasm of such an app is smaller. The gate in the main checkout measuredtests/edge-sizeat 376385 bytes on 61663dda7 and 370402 bytes on 57403acb5 (-5983).tests/edge-full, an app that uses WebSockets, changed from 801471 to 801498 bytes (+27). - Edge builds: an instance keeps the
Cxof an answered request and gives it, clean, to the next request. Before, each request made a newCxon the heap and freed it. A request that starts while the keptCxis in use gets a new one. The native server does not change. On Deno.serve/(Paris, Wisp 20e72be83 with the edgefull2 patch, median of 11, A/A runs equal), it runs 19.35k user instructions per request, not 19.62k. Raw Deno does not change. The edge-size wasm grows by 3051 bytes. - Edge builds: through the fetch handler (
serve), the bridge does not read the body of a GET or HEAD request. The app gets these requests with no body. On Deno 2.9.7 and Bun,request.bodyof a GET withcontent-length: 5or a chunked body isnull(raw-socket run). So the change does not change what an app gets on these two hosts. The native server still gives a GET body tocx.body(). On Deno.serve/(Paris, Wisp 8cbd05281 on 7e9c4e1d1, median of 11), it runs 290 fewer instructions per request (20.78k to 20.49k). Raw sockets do not change. - Edge builds: the header cache of a lazy request is behind one pointer. A request that reads no header makes no cache. A request that reads one uses the cleared cache of the last request.
- Edge builds:
setupruns once per instance, inprepare. It does not run for each request. The setup change alone is inside the spread of the runs. The two changes above together, on Deno.serve/(Paris, Wisp 4f7230291 on 17eff84f0, median of 11), run 340 fewer instructions per request (21.12k to 20.78k). Raw sockets do not change. Native routes do not change. - The edge build answers a request to a sync
+server.rsarm (App::handle_now) in the call of the host, with no task, as the epoll driver of the native server does. An error page, an arm that waits, a stream, a WebSocket and changes not yet saved go on through the task. An app with abeforehook has no such arm. Raw sockets of Node, Bun and Deno answer such an arm the same way. The wasm build leaves out the async shim of such an arm. On/(Paris, Wisp 01c3222cf on 2280dd0a5, median of 11), Deno.serve runs 890 fewer instructions per request (20.51k to 19.62k) and raw sockets run 300 fewer (21.34k to 21.04k).