diff --git a/.prettierrc.mjs b/.prettierrc.mjs index 411021b1a3d5bec..c9657638b29ef01 100644 --- a/.prettierrc.mjs +++ b/.prettierrc.mjs @@ -1,7 +1,11 @@ // @ts-check /** @type {import("prettier").Config} */ export default { - plugins: ["prettier-plugin-astro", "prettier-plugin-tailwindcss"], + plugins: [ + "prettier-plugin-astro", + "prettier-plugin-tailwindcss", + "./plugins/prettier-plugin-mdx-inline/index.mjs", + ], useTabs: true, overrides: [ { @@ -10,5 +14,18 @@ export default { parser: "astro", }, }, + // Prettier's MDX formatter wraps inline JSX elements (like and + // ) onto new lines, which causes MDX v2+ to inject

+ // tags inside them — breaking the rendered HTML. This custom plugin + // prevents that by keeping configured elements on a single line. + // This may become unnecessary once prettier adds MDX v3 support: + // https://github.com/prettier/prettier/issues/12209 + { + files: "*.mdx", + options: { + parser: "mdx-inline", + mdxInlineElements: "code,GlossaryTooltip", + }, + }, ], }; diff --git a/plugins/prettier-plugin-mdx-inline/index.mjs b/plugins/prettier-plugin-mdx-inline/index.mjs new file mode 100644 index 000000000000000..c55417c51ff7fa8 --- /dev/null +++ b/plugins/prettier-plugin-mdx-inline/index.mjs @@ -0,0 +1,188 @@ +/** + * prettier-plugin-mdx-inline + * + * Prevents prettier from reformatting specific JSX elements in MDX files. + * + * Problem: Prettier's MDX formatter treats standalone JSX elements (like + * ``) as block-level and wraps their children + * onto new lines when they exceed printWidth. MDX v2+ then interprets those + * newlines as markdown paragraph boundaries, injecting

tags inside inline + * elements — producing broken HTML like `

...

`. + * + * Solution: This plugin intercepts the parsed MDX AST and converts matching + * JSX nodes to opaque HTML nodes that prettier outputs verbatim. It also + * collapses any existing multi-line formatting back to a single line. + * + * Configuration (.prettierrc.mjs): + * + * export default { + * plugins: ["./prettier-plugin-mdx-inline/index.mjs"], + * overrides: [{ + * files: "*.mdx", + * options: { parser: "mdx-inline" }, + * }], + * }; + * + * You must specify which elements to protect via `mdxInlineElements`: + * + * overrides: [{ + * files: "*.mdx", + * options: { + * parser: "mdx-inline", + * mdxInlineElements: "code,GlossaryTooltip", + * }, + * }], + */ + +/** + * Extract the element name from the start of a JSX string. + * e.g., "" → "code", "" → "GlossaryTooltip" + */ +function getElementName(value) { + const match = value.trim().match(/^<([a-zA-Z][a-zA-Z0-9]*)/); + return match ? match[1] : null; +} + +/** + * Collapse a multi-line JSX element value onto a single line. + * + * Handles: + * - {" "} spacer expressions inserted by prettier + * - Newlines with surrounding whitespace from indentation + * - Multiple consecutive spaces from collapsing + * - Trailing content after the closing tag (e.g., in list items) + * + * Preserves: + * - Attribute values (strings in the opening tag) + * - Self-closing tags within content (e.g., ) + */ +function collapseInlineJsx(value) { + // Remove {" "} spacers — these are prettier artifacts for preserving spaces + let result = value.replace(/\{" "\}/g, " "); + + const elementName = getElementName(result); + if (!elementName) return result; + + // Find the end of the opening tag by tracking string context. + // We need to skip over attribute values that may contain '>' characters. + let inString = false; + let stringChar = ""; + let openTagEnd = -1; + + for (let i = 0; i < result.length; i++) { + const ch = result[i]; + if (inString) { + if (ch === stringChar && result[i - 1] !== "\\") { + inString = false; + } + } else if (ch === '"' || ch === "'") { + inString = true; + stringChar = ch; + } else if (ch === ">") { + openTagEnd = i; + break; + } + } + + if (openTagEnd === -1) return result; + + // Find the matching closing tag — it may not be at the very end of the + // value if there is trailing content (e.g., in a list item where the + // description text follows the within the same JSX node). + const closeTag = ``; + const closeTagIndex = result.indexOf(closeTag, openTagEnd); + if (closeTagIndex === -1) return result; + + const openTag = result.substring(0, openTagEnd + 1); + const content = result.substring(openTagEnd + 1, closeTagIndex); + const trailing = result.substring(closeTagIndex + closeTag.length); + + // Collapse whitespace in the content between tags + const collapsed = content + .replace(/\n\s*/g, " ") // newlines + indentation → single space + .replace(/\s{2,}/g, " ") // multiple spaces → single space + .trim(); + + return openTag + collapsed + closeTag + trailing; +} + +/** + * Parse the configured element list from the options. + */ +function getInlineElements(options) { + const configured = options.mdxInlineElements; + if (!configured || typeof configured !== "string") { + return []; + } + return configured + .split(",") + .map((s) => s.trim()) + .filter(Boolean); +} + +/** + * Check if a JSX node value starts with one of the inline element names. + */ +function isInlineElement(value, elements) { + const trimmed = value.trim(); + for (const el of elements) { + if (trimmed.startsWith(`<${el}>`) || trimmed.startsWith(`<${el} `)) { + return true; + } + } + return false; +} + +/** + * Walk the AST and convert matching JSX nodes to HTML nodes. + */ +function transformAst(ast, elements) { + function walk(node) { + if (node.type === "jsx" && isInlineElement(node.value, elements)) { + // Convert to HTML type so prettier outputs it verbatim + node.type = "html"; + // Collapse multi-line content back to a single line + node.value = collapseInlineJsx(node.value); + } + if (node.children) { + node.children.forEach(walk); + } + } + walk(ast); + return ast; +} + +/** @type {import("prettier").Plugin} */ +const plugin = { + options: { + mdxInlineElements: { + type: "string", + category: "MDX", + default: "", + description: + "Comma-separated list of JSX element names that should not be reformatted.", + }, + }, + + parsers: { + "mdx-inline": { + async parse(text, options) { + // Delegate to the built-in MDX parser via prettier's stable plugin export + const { parsers } = await import("prettier/plugins/markdown"); + const ast = await parsers.mdx.parse(text, options); + + // Transform matching JSX nodes to prevent reformatting + const elements = getInlineElements(options); + transformAst(ast, elements); + + return ast; + }, + // Use the built-in mdast printer — we only modify the AST + astFormat: "mdast", + locStart: (node) => node.position?.start?.offset ?? 0, + locEnd: (node) => node.position?.end?.offset ?? 0, + }, + }, +}; + +export default plugin; diff --git a/src/content/docs/api-shield/security/jwt-validation/index.mdx b/src/content/docs/api-shield/security/jwt-validation/index.mdx index 8a06095e6565184..4cd67c0fe1d878f 100644 --- a/src/content/docs/api-shield/security/jwt-validation/index.mdx +++ b/src/content/docs/api-shield/security/jwt-validation/index.mdx @@ -14,7 +14,6 @@ import { DashButton, } from "~/components"; -{/* prettier-ignore */} JSON web tokens (JWT) are often used as part of an authentication component on many web applications today. Since JWTs are crucial to identifying users and their access, ensuring the token’s integrity is important. API Shield’s JWT validation stops JWT replay attacks and JWT tampering by cryptographically verifying incoming JWTs before they are passed to your API origin. JWT validation will also stop requests with expired tokens or tokens that are not yet valid. @@ -126,7 +125,7 @@ API Shield will verify JSON Web Tokens regardless of whether or not they have th ### Ignore `OPTIONS` pre-flight CORS requests -Due to cross-origin resource sharing (CORS) security, web browsers will send "pre-flight" requests using the `OPTIONS` verb to API endpoints before sending a `GET` (or other verb) request. By definition, `OPTIONS` requests do not include headers or cookies and are anonymous. +Due to cross-origin resource sharing (CORS) security, web browsers will send "pre-flight" requests using the `OPTIONS` verb to API endpoints before sending a `GET` (or other verb) request. By definition, `OPTIONS` requests do not include headers or cookies and are anonymous. If you expect web browsers to be valid clients of your API, and to prevent blocking `OPTIONS` requests from those browsers, Cloudflare recommends adding `or http.request.method eq "OPTIONS"` to your JWT validation rules. @@ -137,6 +136,7 @@ If you expect web browsers to be valid clients of your API, and to prevent block JWT validation is available for all API Shield customers. Enterprise customers who have not purchased API Shield can preview [API Shield as a non-contract service](https://dash.cloudflare.com/?to=/:account/:zone/security/api-shield) in the Cloudflare dashboard or by contacting your account team. --- + ## Limitations Currently, the following known limitations exist: diff --git a/src/content/docs/api-shield/security/schema-validation/index.mdx b/src/content/docs/api-shield/security/schema-validation/index.mdx index d4b18e063754e66..0fb3706749e6381 100644 --- a/src/content/docs/api-shield/security/schema-validation/index.mdx +++ b/src/content/docs/api-shield/security/schema-validation/index.mdx @@ -29,7 +29,6 @@ You can migrate to Schema validation 2.0 manually by uploading your schemas to t ## Process -{/* prettier-ignore */} Endpoints must be added to [Endpoint Management](/api-shield/management-and-monitoring/endpoint-management/) for Schema validation to protect them. Uploading a schema via the Cloudflare dashboard will automatically add endpoints, or you can manually add them from [API Discovery](/api-shield/security/api-discovery/). If you are uploading a schema via the API or Terraform, you must parse the schema and add your endpoints manually. @@ -434,12 +433,12 @@ Schema validation inspects request bodies up to a maximum size that depends on y The default body size limits are: -| Plan | Default body size limit | -| --- | --- | -| Free | 1 KB | -| Pro | 8 KB | -| Business | 8 KB | -| Enterprise | 128 KB | +| Plan | Default body size limit | +| ---------- | ----------------------- | +| Free | 1 KB | +| Pro | 8 KB | +| Business | 8 KB | +| Enterprise | 128 KB | :::note This limit is separate from the [WAF maximum body inspection size](/waf/managed-rules/#maximum-body-size), which controls how much of the request payload the WAF scans. Increasing one does not affect the other. diff --git a/src/content/docs/durable-objects/api/base.mdx b/src/content/docs/durable-objects/api/base.mdx index 83ec929557f66c3..1963436446587a0 100644 --- a/src/content/docs/durable-objects/api/base.mdx +++ b/src/content/docs/durable-objects/api/base.mdx @@ -56,9 +56,7 @@ class MyDurableObject(DurableObject): ### `fetch` -- - fetch(request ) - +- fetch(request ) : | - Takes an HTTP [Request](https://developers.cloudflare.com/workers/runtime-apis/request/) and returns an HTTP @@ -93,16 +91,11 @@ export class MyDurableObject extends DurableObject { ### `alarm` -- - alarm(alarmInfo? ) - +- alarm(alarmInfo? ) : | - Called by the system when a scheduled alarm time is reached. - - The `alarm()` handler has guaranteed at-least-once execution and will be retried upon failure using exponential backoff, starting at two second delays for up to six retries. Retries will be performed if the method fails with an uncaught exception. - - This method can be `async`. - - Refer to [Alarms](/durable-objects/api/alarms/) for more information. #### Parameters @@ -132,10 +125,7 @@ export class MyDurableObject extends DurableObject { ### `webSocketMessage` -- - webSocketMessage(ws , message{" "} - ) - +- webSocketMessage(ws , message ) : | - Called by the system when an accepted WebSocket receives a message. - This method is not called for WebSocket control frames. The system will respond to an incoming [WebSocket @@ -170,10 +160,7 @@ export class MyDurableObject extends DurableObject { ### `webSocketClose` -- - webSocketClose(ws , code , - reason , wasClean ) - +- webSocketClose(ws , code , reason , wasClean ) : | - Called by the system when a WebSocket connection is closed. - With the [`web_socket_auto_reply_to_close`](/workers/configuration/compatibility-flags/#websocket-auto-reply-to-close) compatibility flag (enabled by default on compatibility dates on or after `2026-04-07`), the runtime automatically sends a reciprocal Close frame and transitions `readyState` to `CLOSED` before this handler is called. You do not need to call `ws.close()` — but doing so is safe (the call is silently ignored). @@ -209,9 +196,7 @@ export class MyDurableObject extends DurableObject { ### `webSocketError` -- - webSocketError(ws , error ) - +- webSocketError(ws , error ) : | - Called by the system when a non-disconnection error occurs on a WebSocket connection. - This method can be `async`. diff --git a/src/content/docs/durable-objects/best-practices/websockets.mdx b/src/content/docs/durable-objects/best-practices/websockets.mdx index 698676b042f350e..6b2be96ce283fad 100644 --- a/src/content/docs/durable-objects/best-practices/websockets.mdx +++ b/src/content/docs/durable-objects/best-practices/websockets.mdx @@ -321,9 +321,7 @@ The following methods are available on the Hibernation WebSocket API. Use them t #### `WebSocket.serializeAttachment` -- - serializeAttachment(value ) - +- serializeAttachment(value ) : Keeps a copy of `value` associated with the WebSocket connection. @@ -362,34 +360,35 @@ export class WebSocketServer extends DurableObject { const url = new URL(request.url); const orderId = url.searchParams.get("orderId") ?? "anonymous"; - const webSocketPair = new WebSocketPair(); - const [client, server] = Object.values(webSocketPair); + const webSocketPair = new WebSocketPair(); + const [client, server] = Object.values(webSocketPair); - this.ctx.acceptWebSocket(server); + this.ctx.acceptWebSocket(server); - // Persist per-connection state that survives hibernation - const state: ConnectionState = { - orderId, - joinedAt: Date.now(), - }; - server.serializeAttachment(state); + // Persist per-connection state that survives hibernation + const state: ConnectionState = { + orderId, + joinedAt: Date.now(), + }; + server.serializeAttachment(state); - return new Response(null, { status: 101, webSocket: client }); - } + return new Response(null, { status: 101, webSocket: client }); + } - async webSocketMessage(ws: WebSocket, message: string | ArrayBuffer) { - // Restore state after potential hibernation - const state = ws.deserializeAttachment() as ConnectionState; - ws.send(`Hello ${state.orderId}, you joined at ${state.joinedAt}`); - } + async webSocketMessage(ws: WebSocket, message: string | ArrayBuffer) { + // Restore state after potential hibernation + const state = ws.deserializeAttachment() as ConnectionState; + ws.send(`Hello ${state.orderId}, you joined at ${state.joinedAt}`); + } + + async webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean) { + const state = ws.deserializeAttachment() as ConnectionState; + console.log(`${state.orderId} disconnected`); + // With web_socket_auto_reply_to_close (compat date >= 2026-04-07), the runtime + // auto-replies to Close frames. Calling close() is safe but no longer required. + ws.close(code, reason); + } - async webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean) { - const state = ws.deserializeAttachment() as ConnectionState; - console.log(`${state.orderId} disconnected`); - // With web_socket_auto_reply_to_close (compat date >= 2026-04-07), the runtime - // auto-replies to Close frames. Calling close() is safe but no longer required. - ws.close(code, reason); - } } ```` diff --git a/src/content/docs/ruleset-engine/rules-language/functions.mdx b/src/content/docs/ruleset-engine/rules-language/functions.mdx index 358e0243c504453..d1a54a2716f3df1 100644 --- a/src/content/docs/ruleset-engine/rules-language/functions.mdx +++ b/src/content/docs/ruleset-engine/rules-language/functions.mdx @@ -33,7 +33,6 @@ The Rules language supports these transformation functions: ### `any` -{/* prettier-ignore */} any(): Returns `true` when the comparison operator in the argument returns `true` for _any_ of the values in the argument array. Returns `false` otherwise. @@ -46,7 +45,6 @@ any(url_decode(http.request.body.form.values[*])[*] contains "an xss attack") ### `all` -{/* prettier-ignore */} all(): Returns `true` when the comparison operator in the argument returns `true` for _all_ values in the argument array. Returns `false` otherwise. @@ -59,7 +57,6 @@ all(http.request.headers["content-type"][*] == "application/json") ### `encode_base64` -{/* prettier-ignore */} encode_base64(input [, flags ]): Encodes an `input` string or byte array to Base64 format. @@ -92,7 +89,6 @@ You can only use the `encode_base64()` function in [request/response header tran ### `cidr` -{/* prettier-ignore */} cidr(address , ipv4_network_bits , ipv6_network_bits ): Returns the network address corresponding to an IP address (IPv4 or IPv6), given the provided IPv4 and IPv6 network bits (which determine the corresponding netmasks). @@ -112,7 +108,6 @@ You can only use the `cidr()` function in [custom rules](/waf/custom-rules/) and ### `cidr6` -{/* prettier-ignore */} cidr6(address , ipv6_network_bits ): Returns the IPv6 network address corresponding to an IPv6 address, given the provided network bits (which determine the netmask). If you provide an IPv4 address in the first parameter, it will be returned unchanged. @@ -134,7 +129,6 @@ You can only use the `cidr6()` function in [custom rules](/waf/custom-rules/) an ### `concat` -{/* prettier-ignore */} concat(): Takes a comma-separated list of values. Concatenates the argument values into a single String or array. @@ -145,7 +139,6 @@ For example, `concat("String1", " ", "String", "2")` will return `"String1 Strin ### `decode_base64` -{/* prettier-ignore */} decode_base64(source ): Decodes a Base64-encoded String specified in `source`. @@ -160,7 +153,6 @@ You can only use the `decode_base64()` function in [Transform Rules](/rules/tran ### `ends_with` -{/* prettier-ignore */} ends_with(source , substring ): Returns `true` when the source ends with a given substring. Returns `false` otherwise. The source cannot be a literal value (like `"foo"`). @@ -169,7 +161,6 @@ For example, if `http.request.uri.path` is `"/welcome.html"`, then `ends_with(ht ### `join` -{/* prettier-ignore */} join(items , separator ): Returns a string which is the concatenation of the strings in `items` with the `separator` between each item. @@ -193,7 +184,6 @@ The `join()` function is only available in [Transform Rules](/rules/transform/), ### `has_key` -{/* prettier-ignore */} has_key(map: , key: ): Returns true if the `key` specified in the second argument, which can be a literal or a dynamic string, is an existing key in the `map` provided as first argument; returns false otherwise. @@ -214,7 +204,6 @@ has_key(http.request.headers, lower(http.request.uri.args.names[0])) ### `has_value` -{/* prettier-ignore */} has_value(collection: , value: ): Returns true if the `value` specified in the second argument, which can be a literal or a dynamic value, is found in the `collection` provided as first argument; returns false otherwise. @@ -235,7 +224,6 @@ has_value(http.request.headers.names, http.request.uri.args.names[0]) ### `len` -{/* prettier-ignore */} len(): Returns the byte length of a String or Bytes value, or the number of elements in an array. @@ -244,7 +232,6 @@ For example, if the value of `http.host` is `"example.com"`, then `len(http.host ### `lookup_json_integer` -{/* prettier-ignore */} lookup_json_integer(field , key , key , ...): Returns the integer value associated with the supplied `key` in `field`. @@ -279,7 +266,6 @@ Examples: ### `lookup_json_string` -{/* prettier-ignore */} lookup_json_string(field , key , key , ...): Returns the string value associated with the supplied `key` in `field`. @@ -312,7 +298,6 @@ Examples: ### `lower` -{/* prettier-ignore */} lower(): Converts a string field to lowercase. Only uppercase ASCII bytes are converted. All other bytes are unaffected. @@ -321,7 +306,6 @@ For example, if `http.host` is `"WWW.cloudflare.com"`, then `lower(http.host) == ### `regex_replace` -{/* prettier-ignore */} regex_replace(source , regular_expression , replacement ): Replaces a part of a source string matched by a regular expression with a replacement string, returning the result. The replacement string can contain references to regular expression capture groups (for example, `${1}` and `${2}`), up to eight replacement references. @@ -356,7 +340,6 @@ Currently, the `regex_replace()` function is only available in rewrite expressio ### `remove_bytes` -{/* prettier-ignore */} remove_bytes(): Returns a new byte array with all the occurrences of the given bytes removed. @@ -365,7 +348,6 @@ For example, if `http.host` is `"www.cloudflare.com"`, then `remove_bytes(http.h ### `remove_query_args` -{/* prettier-ignore */} remove_query_args(field , query_param1 , query_param2 , ...): Removes one or more query string parameters from a URI query string. Returns a string without the specified parameters. @@ -402,7 +384,6 @@ You can only use the `remove_query_args()` function in [rewrite expressions of T ### `sha256` -{/* prettier-ignore */} sha256(input ): Computes the SHA-256 cryptographic hash of the `input` string or byte array. Returns a 32-byte hash value. @@ -439,7 +420,6 @@ You can only use the `sha256()` function in rewrite expressions of [Transform Ru ### `split` -{/* prettier-ignore */} split(input , separator , limit ): Splits the `input` string into an array of strings by breaking the initial string at every occurrence of the `separator` string. The returned array will contain at most `limit` number of elements. @@ -477,7 +457,6 @@ The `split()` function is only available in [response header transform rules](/r ### `starts_with` -{/* prettier-ignore */} starts_with(source , substring ): Returns `true` when the source starts with a given substring. Returns `false` otherwise. The source cannot be a literal value (like `"foo"`). @@ -486,7 +465,6 @@ For example, if `http.request.uri.path` is `"/blog/first-post"`, then `starts_wi ### `substring` -{/* prettier-ignore */} substring(field , start , end ): Returns part of the `field` value (the value of a String or Bytes [field](/ruleset-engine/rules-language/fields/reference/)) from the `start` byte index up to (but excluding) the `end` byte index. The first byte in `field` has index `0`. If you do not provide the optional `end` index, the function returns the part of the string from `start` index to the end of the string. @@ -506,7 +484,6 @@ substring(http.request.body.raw, 0, -2) will return "asdfgh" ### `to_string` -{/* prettier-ignore */} to_string(): Returns the string representation of an Integer, Boolean, or IP address value. @@ -527,7 +504,6 @@ You can only use the `to_string()` function in rewrite expressions of [Transform ### `upper` -{/* prettier-ignore */} upper(): Converts a string field to uppercase. Only lowercase ASCII bytes are converted. All other bytes are unaffected. @@ -536,7 +512,6 @@ For example, if `http.host` is`"www.cloudflare.com"`, then `upper(http.host)` wi ### `url_decode` -{/* prettier-ignore */} url_decode(source , options ): Decodes a URL-formatted string defined in `source`, as in the following: @@ -569,7 +544,6 @@ url_decode(http.request.uri.path) matches "(?u)\p{Hangul}+" ### `uuidv4` -{/* prettier-ignore */} uuidv4(source ): Generates a random UUIDv4 (Universally Unique Identifier, version 4) based on the given argument (a source of randomness). To obtain an array of random bytes, use the [`cf.random_seed`](/ruleset-engine/rules-language/fields/reference/cf.random_seed/) field. @@ -582,7 +556,6 @@ You can only use the `uuidv4()` function in [rewrite expressions of Transform Ru ### `wildcard_replace` -{/* prettier-ignore */} wildcard_replace(source , wildcard_pattern , replacement , flags ): Replaces a `source` string, matched by a literal with zero or more `*` wildcard metacharacters, with a replacement string, returning the result. The replacement string can contain references to wildcard capture groups (for example, `${1}` and `${2}`), up to eight replacement references. @@ -631,7 +604,6 @@ Currently, you can only use the `wildcard_replace()` function in rewrite express ### `bit_slice` -{/* prettier-ignore */} bit_slice(protocol , offset_start , offset_end ): This function looks for matches on a given slice of bits. diff --git a/src/content/docs/workers/runtime-apis/bindings/worker-loader.mdx b/src/content/docs/workers/runtime-apis/bindings/worker-loader.mdx index e584215d05e5007..0afe53761d1785c 100644 --- a/src/content/docs/workers/runtime-apis/bindings/worker-loader.mdx +++ b/src/content/docs/workers/runtime-apis/bindings/worker-loader.mdx @@ -105,11 +105,7 @@ To add a dynamic worker loader binding to your worker, add it to your Wrangler c ### `get` - - get(id , getCodeCallback{" "} - - ): - +get(id , getCodeCallback ): Loads a Worker with the given ID, returning a `WorkerStub` which may be used to invoke the Worker. diff --git a/src/content/docs/workers/runtime-apis/nodejs/asynclocalstorage.mdx b/src/content/docs/workers/runtime-apis/nodejs/asynclocalstorage.mdx index cb563e43fc19a69..1def01f1fa1eff3 100644 --- a/src/content/docs/workers/runtime-apis/nodejs/asynclocalstorage.mdx +++ b/src/content/docs/workers/runtime-apis/nodejs/asynclocalstorage.mdx @@ -192,9 +192,7 @@ console.log(myResource.doSomething()); // prints 123 - asyncResource.bind(fnfunction, thisArgany) - Binds the given function to the async context associated with this `AsyncResource`. -- - asyncResource.runInAsyncScope(fnfunction, thisArgany, ...argsarguments) - +- asyncResource.runInAsyncScope(fnfunction, thisArgany, ...argsarguments) - Call the provided function with the given arguments in the async context associated with this `AsyncResource`. ## Caveats diff --git a/src/content/docs/workflows/build/workers-api.mdx b/src/content/docs/workflows/build/workers-api.mdx index 47397e7d8ecb9f6..053dcbebe44be2a 100644 --- a/src/content/docs/workflows/build/workers-api.mdx +++ b/src/content/docs/workflows/build/workers-api.mdx @@ -29,7 +29,6 @@ export class MyWorkflow extends WorkflowEntrypoint { ### run -{/* prettier-ignore */} - run(event: WorkflowEvent<T>, step: WorkflowStep): Promise<T> - `event` - the event passed to the Workflow, including an optional `payload` containing data (parameters) - `step` - the `WorkflowStep` type that provides the step methods for your Workflow @@ -75,10 +74,9 @@ Refer to the [events and parameters](/workflows/build/events-and-parameters/) do ### step -{/* prettier-ignore */} - step.do(name: string, callback: (): RpcSerializable): Promise<T> - step.do(name: string, config?: WorkflowStepConfig, callback: (): - RpcSerializable): Promise<T> + RpcSerializable): Promise<T> - `name` - the name of the step, up to 256 characters. - `config` (optional) - an optional `WorkflowStepConfig` for configuring [step specific retry behaviour](/workflows/build/sleeping-and-retrying/). - `callback` - an asynchronous function that optionally returns serializable state for the Workflow to persist. In JavaScript Workflows, this includes a fresh, unlocked `ReadableStream` for large binary output. @@ -130,13 +128,11 @@ export class MyWorkflow extends WorkflowEntrypoint { -{/* prettier-ignore */} - step.sleep(name: string, duration: WorkflowDuration): Promise<void> - `name` - the name of the step. - `duration` - the duration to sleep until, in either seconds or as a `WorkflowDuration` compatible string. - Refer to the [documentation on sleeping and retrying](/workflows/build/sleeping-and-retrying/) to learn more about how Workflows are retried. -{/* prettier-ignore */} - step.sleepUntil(name: string, timestamp: Date | number): Promise<void> - `name` - the name of the step. - `timestamp` - a JavaScript `Date` object or milliseconds from the Unix epoch to sleep the Workflow instance until. @@ -217,7 +213,6 @@ Note that Workflows on Workers Free have a limit of 1,024 steps. Refer to [Workf ## NonRetryableError -{/* prettier-ignore */} - throw new NonRetryableError(message: , name ): - When thrown inside [`step.do()`](/workflows/build/workers-api/#step), this error stops step retries, propagating the error to the top level (the [run](/workflows/build/workers-api/#run) function). Any error not handled at this top level will cause the Workflow instance to fail. - Refer to the [documentation on sleeping and retrying](/workflows/build/sleeping-and-retrying/) to learn more about how Workflows steps are retried. @@ -317,7 +312,6 @@ The `Workflow` type exports the following methods: Create (trigger) a new instance of the given Workflow. -{/* prettier-ignore */} - create(options?: WorkflowInstanceCreateOptions): Promise<WorkflowInstance> - `options` - optional properties to pass when creating an instance, including a user-provided ID and payload parameters. @@ -381,7 +375,6 @@ Create (trigger) a batch of new instance of the given Workflow, up to 100 instan This is useful when you are scheduling multiple instances at once. A call to `createBatch` is treated the same as a call to `create` (for a single instance) and allows you to work within the [instance creation limit](/workflows/reference/limits/). -{/* prettier-ignore */} - createBatch(batch: WorkflowInstanceCreateOptions[]): Promise<WorkflowInstance[]> - `batch` - list of Options to pass when creating an instance, including a user-provided ID and payload parameters. diff --git a/src/content/docs/workflows/python/python-workers-api.mdx b/src/content/docs/workflows/python/python-workers-api.mdx index aded391f4657b58..e771cce95b98357 100644 --- a/src/content/docs/workflows/python/python-workers-api.mdx +++ b/src/content/docs/workflows/python/python-workers-api.mdx @@ -21,7 +21,6 @@ class MyWorkflow(WorkflowEntrypoint): ## WorkflowStep -{/* prettier-ignore */} - step.do(name=None, *, concurrent=False, config=None) — a decorator that allows you to define a step in a workflow. - `name` — an optional name for the step. If omitted, the function name (`func.__name__`) is used. - `concurrent` — an optional boolean that indicates whether dependencies for this step can run concurrently. @@ -57,7 +56,6 @@ Note that the decorator doesn't make the call to the step, it just returns a cal When returning state from a step, you must make sure that the returned value is serializable. Since steps run through an FFI layer, the returned value gets type translated via [FFI.](https://pyodide.org/en/stable/usage/api/python-api/ffi.html#pyodide.ffi.to_js) Refer to [Pyodide's documentation](https://pyodide.org/en/stable/usage/type-conversions.html#type-translations-pyproxy-to-js) regarding type conversions for more information. -{/* prettier-ignore */} - step.sleep(name, duration) - `name` — the name of the step. - `duration` — the duration to sleep until, in either seconds or as a `WorkflowDuration` compatible string. @@ -67,7 +65,6 @@ async def run(self, event, step): await step.sleep("my-sleep-step", "10 seconds") ``` -{/* prettier-ignore */} - step.sleep_until(name, timestamp) - `name` — the name of the step. - `timestamp` — a `datetime.datetime` object or seconds from the Unix epoch to sleep the workflow instance until. @@ -79,7 +76,6 @@ async def run(self, event, step): await step.sleep_until("my-sleep-step", datetime.datetime.now() + datetime.timedelta(seconds=10)) ``` -{/* prettier-ignore */} - step.wait_for_event(name, event_type, timeout="24 hours") - `name` — the name of the step. - `event_type` — the type of event to wait for.