Repository navigation
Conversation
…e tasks Spin does not run after-response tasks. Every converted Spin request now carries a scheduler that rejects registration with 501 Not Implemented and the message exported as edgezero_adapter_spin::AFTER_RESPONSE_UNSUPPORTED, instead of core's generic "not supported by this adapter" message. The task is dropped without being polled. The handle is installed in into_core_request_head, which every native Spin entry point uses (run_app, run_app_with_platform, dispatch_app, AppExt::dispatch, dispatch, dispatch_with_kv_label, into_core_request). The capability matrix already reports Spin Unsupported, so required = ["after-response-tasks"] still refuses Spin. Tests: host unit test for the scheduler; wasm32 contract test dispatching a real SpinRequest. Docs: capabilities, Spin guide, changelog, core after_response docs, design and plan.
Installing a rejecting Spin scheduler changes a zero budget from 501 to 500: core now finds a handle and rejects the budget before the scheduler, as it already does on Axum and Fastly. The guides, changelog and spec claimed every Spin registration returns 501 and that the zero budget case was unchanged. Correct them and pin the 500 with a Spin unit test. Also note that core pre-dispatch hooks can replace or remove the handle (removal falls back to core's 501), that PR #512 overlaps on the CHANGELOG line as well as the capabilities bullet, and point the #509 design at the follow-up.
#509 (2620377) adds bounded work after the response on Fastly and Axum, drained on Axum SIGTERM (EZI-1, #476). #512 (cdc232c) runs it on Cloudflare through waitUntil (#478), and #515 (ec347a2) reports Spin's capability error (#483). The line now stacks on #517 and each PR merged the one below it, so this merge is clean.
|
For Trusted Server's identity integration chain, this PR now stacks on #512 instead of #509: the two conflicted in Checked locally at |
Fixtures that poll a non-blocking std TcpListener read the accepted stream with set_read_timeout. macOS accept(2) copies O_NONBLOCK to the accepted socket (Linux does not), so those reads failed with WouldBlock at once and tests failed at random on macOS under parallel load. Add a small accept_blocking helper per crate (store-aws, adapter-axum tests, cli tests) that restores blocking mode, route all nine accept sites through it, and cover it with a test that fails on macOS when the accepted stream does not wait for its read timeout.
Four production_hosting tests drive the native proxy fixture, which binds its upstream socket to 127.0.0.2 or 127.0.0.3 so the server sees distinct peers. Linux routes all of 127.0.0.0/8 to lo; macOS lo0 has only 127.0.0.1, so the bind fails with EADDRNOTAVAIL, the relay drops the connection, and the tests see an empty response or TLS UnexpectedEof. Ignore them off Linux with a reason that gives the lo0 alias commands needed to run them with --ignored.
The SDK's 100 ms attempt deadline runs from the start of the attempt.
Under parallel load the child can be descheduled between the TCP connect
and the request write, so the SDK correctly abandons the connection
before sending anything. The fixture treated that as fatal ("SDK closed
before request headers"), which failed the test about once in 20 full
store-aws runs on macOS.
The test now uses a fixture that accepts every attempt and never
answers, recording whether the client closed each connection itself. The
operation budget is 10 s, so only the attempt deadline can close a held
connection within the 5 s bound. The test asserts that every attempt was
closed that way, that the SDK made 1 to 3 attempts, and that any full
request named the fixture ARN. Removing the attempt timeout from the
provider makes the test fail.
macOS marks a new socket close-on-exec only after socket() returns. When a parallel test spawned a fixture process in that gap, the child inherited another test's port reservation and kept it bound after the test released it. That test's fixture server then failed to bind (AddrInUse); lsof showed another fixture process holding the port as a CLOSED socket. Separately, a released reservation could be served by another test's server during a "nothing answers" check. Together these failed 6 of 20 macOS runs. Reservations and fixture spawns now hold one lock, so they never overlap. Tests that assert nothing answers keep their reservation bound, but not listening, until the check is done.
production_hosting: client streams from Server::socket and raw_request also take the reservation/spawn lock, so a concurrently spawned fixture cannot inherit one and keep the connection open after the test drops it. Because a held reservation always refuses connections, "nothing answers" checks now also assert that the server never reached its listener bind. Secrets Manager: the holding fixture drains every queued connection after the child exits before counting attempts, so a starved fixture thread cannot undercount them.
|
Round 12 identity realignment:
This PR also merges #519. Each merge message says what it carries and how any conflict was resolved. |
|
Round 15 identity realignment:
Each merge message says what it carries and how any conflict was resolved. |
…causes A refused registration gives its slot back, so Spin never reaches the 64-task limit.
Review follow-up: fixes committed to this branchA full review of this PR turned up the problems below; each would otherwise have needed a follow-up ticket, so it is fixed on this branch instead. Every item names its commit.
Fixes made on the PRs below this one in the stack were merged into this branch with merge commits, including #519's (the production-hosting |
Summary
ctx.after_response(budget, task)on Spin fell through to core's generic501 after-response tasks are not supported by this adapter. That error looks the same as a bare core context or an adapter that forgot to install a scheduler.501 Not Implemented(kindnot_implemented) withafter-response tasks are not supported by the Spin adapter, exported asedgezero_adapter_spin::AFTER_RESPONSE_UNSUPPORTED. The task is dropped without being polled.501for any budget. With a handle installed, zero or over-30-second budgets return500before the scheduler runs; the 64-task check also precedes scheduling. Managed Cloudflare requests on the current Enable Cloudflare after-response tasks with gated waitUntil #512 base have the same validation precedence.Unsupported, sorequired = ["after-response-tasks"]still refuses Spin atbuild/serve/deploy.Stacked on #512 (
feature/478-cloudflare-after-response), which includes #509 and its portable API/capability. #509 was the original design base. The Cloudflare implementation of #478 is already in the current base; the capability guide and changelog are reconciled with it.Design:
docs/superpowers/specs/2026-11-18-spin-after-response-error-design.md; plan:docs/superpowers/plans/2026-11-18-spin-after-response-error.md.Integration note (historical comparison): a
git merge-treecomparison with #496 reported conflicts in Axum response conversion, Cloudflare/Spin contracts, and core error/extractor code. These siblings need reconciliation when integrated.Changes
edgezero-adapter-spin/src/after_response.rs(new)AfterResponseScheduler: drops the task and returnsEdgeError::not_implemented(AFTER_RESPONSE_UNSUPPORTED); host unit tests: poll and drop probes, and zero budget returns 500edgezero-adapter-spin/src/lib.rspub const AFTER_RESPONSE_UNSUPPORTED; module gated likeingressedgezero-adapter-spin/src/request.rsinto_core_request_headinserts the handle. This coversrun_app,run_app_with_platform,dispatch_app,AppExt::dispatch,dispatch,dispatch_with_kv_labelandinto_core_requestedgezero-adapter-spin/tests/contract.rsSpinRequestthroughdispatch_requestto a route that registers a task gets the Spin 501; the task is never polled and is dropped once; a control route returns 200edgezero-core/src/after_response.rs,src/context.rsdocs/superpowers/specs/2026-11-17-after-response-tasks-design.mdCHANGELOG.mddocs/superpowers/{specs,plans}/2026-11-18-spin-after-response-error*.mdThe test-utils
dispatch_ingress_*bridges build core requests without a handle and retain core's generic 501.send_assembly_errorhas no app or handlers and does not register tasks.Closes
Closes #483
This PR targets
feature/478-cloudflare-after-response, so merging it into that branch does not automatically close the linked issue(s); close them manually or upon default-branch integration.Review follow-up
bbcb62f1 corrects validation precedence across the public docs and module introductions: no handle returns generic 501 for any budget; an installed handle checks zero/over-limit budget and task capacity before calling a rejecting scheduler. The spec/plan distinguish original #509 history from the current #512 base and record completed changelog/capability reconciliation. Executable Rust and tests are unchanged.
Local evidence for the documentation commit bbcb62f (Rust 1.98.1, Node 24.20.0): all five required Cargo gates; isolated harness (680 passed, 4 ignored); nine core and two Spin focused tests; docs lint/Prettier/build and outbound-doc contract; strict native public rustdoc. Independent source review confirmed comment-only Rust changes and preserved unpolled disposal/slot rollback.
Additional strict private-rustdoc runs expose existing links in unchanged Spin files (
config_store,key_value_store,kv_pagination,request); those broader private-doc configurations remain unqualified. No warnings were suppressed. Hosted Actions for bbcb62f later failed as described below. No new hosted deployment or full runtime qualification was performed for this documentation follow-up.CI follow-up
CI follow-up cb37b00e refreshes only pin-project-lite version/checksum to 0.2.19 in the six active lockfiles after 0.2.17 was yanked. Fresh offline logging and generated AWS/Dynamo/celld proofs pass. A separate test-only correction supplies scoped fixture identity and a fake compiler so cancellation tests reach fake Cargo before their unchanged startup deadline; production fingerprinting is unchanged. All five required Cargo gates, three WASM target checks and the full harness (681 passed, 4 ignored; two test threads) pass. The earlier macOS shutdown race is not claimed fixed. All 30 hosted checks now pass on cb37b00, including the workspace and genuine generated-consumer CLI jobs. The processed Rust CodeQL analysis is clean (27 rules, no errors, warnings or findings), as are the other configured languages.
The bbcb62f hosted workspace/CLI failures reproduced with a pristine cache containing only the locked, now-yanked 0.2.17. Locked fetch with 0.2.19 restores eligible dependencies for genuine fresh offline consumers; no fixture lockfile was injected and no network access was added to Rust tests. The generated runtime proofs retain their build and startup assertions.
The separate native AWS advisory failed while pulling its pinned Moto image, before contract tests ran. The immutable pin is unchanged; public-registry availability does not qualify Docker execution. Earlier default-concurrency macOS harness failures are retained as a limitation; the final full pass uses two test threads. The existing private-rustdoc limitations above remain.
Test plan
Historical author-reported local verification below (original head unrecorded unless an explicit SHA is given). These results, counts, timings and negative controls were not rerun in this audit, and their underlying local logs were unavailable; checked boxes retain the original report. The earlier
da0471b7revision had 29 reported passing hosted checks; that result is historical and does not verify the current review-follow-up commit.Local, Rust 1.98.1 (pinned) and Node 24.20.0:
cargo test --workspace --all-targets(2824 passed)cargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcargo check --workspace --all-targets --features "fastly cloudflare spin"wasm32-wasip2(Spin):cargo check -p edgezero-adapter-spin --target wasm32-wasip2 --features spin, plus Spin wasm clippy forspinandspin,test-utils. Fastly and Cloudflare are untouched and were not rebuilt.examples/app-demoworkspace:cd examples/app-demo && cargo test --workspace --all-targets(68 passed)cd docs && npm run lint && npm run format && npm run build;node scripts/check_outbound_docs_contract.mjsedgezero serve --adapter axum: not applicable (Spin-only change); runtime check below used Spin.--test contract --test sdk_resourcesunder Wasmtime 48.0.2 (36 + 25 passed);adapter_capability_matrix_matches_contracts(--features cli).spin up4.1.0. A scratch copy ofexamples/app-demogot an/after-taskroute, which propagates the registration error with?and whose task would print a stderr marker. The same copy was built from this branch and from Add bounded after-response tasks on Fastly and Axum #509:501 {"error":{"kind":"not_implemented","message":"after-response tasks are not supported by the Spin adapter","status":501}}on two consecutive requests.501 ... not supported by this adapter./and/echo/spinreturn 200 on both builds.Hosted Spin (Akamai Functions) was not exercised. These historical results do not qualify the current revision; see the review follow-up above for current local evidence and hosted status.
Checklist
{id}syntax (not:id)edgezero_core(nothttpcrate)KvRegistry/ConfigRegistry/SecretRegistry(not the legacy single-handle setters); store wiring is unchanged