Minor Changes
-
#2980
570333aThanks @logelog! - AddsgetVersioned,compareAndSetandcompareAndDeleteto plugin storage collections andctx.kv. Native and sandboxed plugins can create an absent key or condition a replacement or deletion on the revision they read, preventing concurrent requests from silently overwriting each other.Pass an explicit
nullrevision to create only when absent. A successful replacement returns its new revision; a conflict returns{ applied: false }. Invalid input, permission failures and database failures reject the promise. Atomicity applies to one key, so changes spanning multiple records still require an application-level protocol.Update core and the sandbox adapter together and apply the host database migrations before using the methods. The migration initializes existing records without a backfill. Stored values are preserved, and existing unconditional writes continue to work while invalidating old revisions. Conditional keys are limited to 1,024 JavaScript string characters and values to 1 MiB of UTF-8 JSON.
Patch Changes
-
#3050
4c89130Thanks @logelog! - Fixes plugin HTTP requests withallowedHostsso initial URLs and redirects also pass SSRF validation. Requests are rejected when URL or DNS validation identifies an unsupported scheme or a non-public address.Existing callers of the shared outbound URL validator also reject these non-public ranges.
The default validator resolves public hostnames through
cloudflare-dns.combefore dispatch. Self-hosted deployments must permit access to that endpoint when using the default resolver. -
#2169
107c3ccThanks @vedanshujain! - Addsctx.storage.<collection>.updateIf(id, { where, set?, delta? })for atomic conditional updates to existing plugin documents. Usewhereto check stored fields,setto replace field values, anddeltato increment or decrement integer counters. The method returns{ applied: true, data }with the updated document, or{ applied: false }when the document is absent or the condition fails. It never inserts a document.Malformed update arguments reject without writing. Deltas require safe integer operands and results; missing or
nullcounters start at0. Invalid stored counters, overflow, and non-object documents return{ applied: false }without changing any fields.Available to native plugins and sandboxed plugins on Cloudflare and Workerd, with SQLite, D1, and PostgreSQL support. PostgreSQL serialization failures and deadlocks expose
code: "STORAGE_SERIALIZATION_FAILURE"andretryable: true, including across sandbox transports. Retry standalone calls with bounded backoff, or restart the entire explicit transaction. -
#3041
0ae2f26Thanks @danielmlr! - Adds the cause to theSANDBOX_NOT_AVAILABLEerror and to the "Plugin sandbox is configured but not available on this platform" startup warning when a configured sandbox runner cannot run plugins. On Cloudflare Workers the message names the missingworker_loadersbinding orPluginBridgeexport; on Node.js it says that theworkerdbinary did not run.Sandbox runners report the cause through a new optional
unavailableReason()method onSandboxRunner. Runners without it keep the previous messages. -
#2967
c531f30Thanks @danielmlr! - Fixes the workerd plugin sandbox loggingPlugins will run unsandboxedafter it stops restarting a repeatedly crashingworkerd, when in fact every sandboxed hook and route fails from that point. The log line now names that consequence, and the reason onSandboxUnavailableErrordistinguishes a spent crash budget from a runner that never started. -
Updated dependencies [
36a021c,573230f,2b2f69e,33cb7f0,befce6d,cd3e391,3f516f4,b73a133,b1ccecd,fea6beb,3bd30da,e13fa01,f9ac286,0bcb1d9,4c89130,107c3cc,107c3cc,91a4aef,ef22a2d,f0af9a1,dd5ef1a,0ae2f26,27e432e,d409722,8b3fd50,1a71c9e,91a4aef,570333a]:- emdash@0.38.0