From ff2689f084c98b16c12059185787d9f97c18238e Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Mon, 10 Feb 2025 16:40:48 +0000 Subject: [PATCH 1/5] Add check startup docs --- src/content/docs/workers/platform/limits.mdx | 2 ++ .../docs/workers/wrangler/commands.mdx | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/content/docs/workers/platform/limits.mdx b/src/content/docs/workers/platform/limits.mdx index 63b5fb897ba0738..a7768d52713d169 100644 --- a/src/content/docs/workers/platform/limits.mdx +++ b/src/content/docs/workers/platform/limits.mdx @@ -272,6 +272,8 @@ You can measure your Worker's startup time by deploying it to Cloudflare using [ If you are having trouble staying under this limit, consider [profiling using DevTools](/workers/observability/dev-tools/) locally to learn how to optimize your code. +When a Worker deployment fails with a startup time error Wrangler will automatically generate a CPU profile for easy investigation, This can be imported into Chrome DevTools or opened directly in VSCode. Refer to [`wrangler check startup`](/workers/wrangler/commands/#startup) for more details. + --- diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 2928ae791c87ff9..1e7510062713533 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -48,6 +48,7 @@ Wrangler offers a number of commands to manage your Cloudflare Workers. - [`cert`](#cert) - Manage certificates used for mTLS and Certificate Authority (CA) chain connections. - [`types`](#types) - Generate types from bindings and module rules in configuration. - [`telemetry`](#telemetry) - Configure whether Wrangler can collect anonymous usage data. +- [`check`](#check) - Validate your Worker. :::note @@ -1966,3 +1967,26 @@ This will resolve the global status set by `wrangler telemetry disable / enable` ```txt wrangler telemetry status ``` + + + +--- + +## `check` + +### `startup` + +Generate a CPU profile of your Worker's startup phase. + +This can be imported into Chrome DevTools or opened directly in VSCode to view a flamegraph of your Worker's startup phase. Additionally, when a Worker deployment fails with a startup time error Wrangler will automatically generate a CPU profile for easy investigation. + +```sh +wrangler check startup +``` + +- `--deploy-args` + - To customise the way `wrangler check startup` builds your Worker for analysis, provide the exact arguments you use when deploying your Worker with `wrangler deploy`. For instance, if you deploy your Worker with `wrangler deploy --no-bundle`, you should use `wrangler check startup --deploy-args="--no-bundle"` to profile the startup phase. +- `--worker-bundle` + - If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialised multipart upload, with the exact same format as [the API expects](https://developers.cloudflare.com/api/resources/workers/subresources/scripts/methods/update/) + + From dbad842e657bdec5ac164b1ba8388c3a5e4ac59d Mon Sep 17 00:00:00 2001 From: ToriLindsay Date: Tue, 11 Feb 2025 14:56:26 +0000 Subject: [PATCH 2/5] Update src/content/docs/workers/wrangler/commands.mdx Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- src/content/docs/workers/wrangler/commands.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 1e7510062713533..c9ce213198883ab 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -1987,6 +1987,6 @@ wrangler check startup - `--deploy-args` - To customise the way `wrangler check startup` builds your Worker for analysis, provide the exact arguments you use when deploying your Worker with `wrangler deploy`. For instance, if you deploy your Worker with `wrangler deploy --no-bundle`, you should use `wrangler check startup --deploy-args="--no-bundle"` to profile the startup phase. - `--worker-bundle` - - If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialised multipart upload, with the exact same format as [the API expects](https://developers.cloudflare.com/api/resources/workers/subresources/scripts/methods/update/) + - If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialised multipart upload, with the exact same format as [the API expects](/api/resources/workers/subresources/scripts/methods/update/) From d3bb20ed149a994206e85611acd99a61da24f342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Somhairle=20MacLe=C3=B2id?= Date: Wed, 26 Feb 2025 23:49:00 +0000 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Brendan Irvine-Broque Co-authored-by: ToriLindsay --- src/content/docs/workers/platform/limits.mdx | 2 +- src/content/docs/workers/wrangler/commands.mdx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/docs/workers/platform/limits.mdx b/src/content/docs/workers/platform/limits.mdx index a7768d52713d169..92644977aee383e 100644 --- a/src/content/docs/workers/platform/limits.mdx +++ b/src/content/docs/workers/platform/limits.mdx @@ -272,7 +272,7 @@ You can measure your Worker's startup time by deploying it to Cloudflare using [ If you are having trouble staying under this limit, consider [profiling using DevTools](/workers/observability/dev-tools/) locally to learn how to optimize your code. -When a Worker deployment fails with a startup time error Wrangler will automatically generate a CPU profile for easy investigation, This can be imported into Chrome DevTools or opened directly in VSCode. Refer to [`wrangler check startup`](/workers/wrangler/commands/#startup) for more details. +When you attempt to deploy a Worker using the [Wrangler CLI](/workers/wrangler/), but your deployment is rejected because your Worker exceeds the [maximum startup time](workers/platform/limits/#worker-startup-time), Wrangler will automatically generate a CPU profile that you can import into Chrome DevTools or open directly in VSCode. You can use this to learn what code in your Worker uses large amounts of CPU time at startup. Refer to [`wrangler check startup`](/workers/wrangler/commands/#startup) for more details. diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index c9ce213198883ab..7c5cff255df6aed 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -1978,7 +1978,7 @@ wrangler telemetry status Generate a CPU profile of your Worker's startup phase. -This can be imported into Chrome DevTools or opened directly in VSCode to view a flamegraph of your Worker's startup phase. Additionally, when a Worker deployment fails with a startup time error Wrangler will automatically generate a CPU profile for easy investigation. +After you run `wrangler check startup`, you can import the profile into Chrome DevTools or open it directly in VSCode to view a flamegraph of your Worker's startup phase. Additionally, when a Worker deployment fails with a startup time error Wrangler will automatically generate a CPU profile for easy investigation. ```sh wrangler check startup @@ -1987,6 +1987,6 @@ wrangler check startup - `--deploy-args` - To customise the way `wrangler check startup` builds your Worker for analysis, provide the exact arguments you use when deploying your Worker with `wrangler deploy`. For instance, if you deploy your Worker with `wrangler deploy --no-bundle`, you should use `wrangler check startup --deploy-args="--no-bundle"` to profile the startup phase. - `--worker-bundle` - - If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialised multipart upload, with the exact same format as [the API expects](/api/resources/workers/subresources/scripts/methods/update/) + - If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialized multipart upload, with the exact same format as [the API expects](/api/resources/workers/subresources/scripts/methods/update/) From 927a2dfb6ef5c49dcad266e4978ea848d4758265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Somhairle=20MacLe=C3=B2id?= Date: Wed, 26 Feb 2025 23:53:05 +0000 Subject: [PATCH 4/5] Update commands.mdx --- src/content/docs/workers/wrangler/commands.mdx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 7c5cff255df6aed..bfb5ba3362a4207 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -1984,9 +1984,11 @@ After you run `wrangler check startup`, you can import the profile into Chrome D wrangler check startup ``` -- `--deploy-args` - - To customise the way `wrangler check startup` builds your Worker for analysis, provide the exact arguments you use when deploying your Worker with `wrangler deploy`. For instance, if you deploy your Worker with `wrangler deploy --no-bundle`, you should use `wrangler check startup --deploy-args="--no-bundle"` to profile the startup phase. -- `--worker-bundle` - - If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialized multipart upload, with the exact same format as [the API expects](/api/resources/workers/subresources/scripts/methods/update/) +- `--args` + - To customise the way `wrangler check startup` builds your Worker for analysis, provide the exact arguments you use when deploying your Worker with `wrangler deploy`, or your Pages project with `wrangler pages functions build`. For instance, if you deploy your Worker with `wrangler deploy --no-bundle`, you should use `wrangler check startup --args="--no-bundle"` to profile the startup phase. +- `--worker` + - If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialized multipart upload, with the exact same format as [the API expects](/api/resources/workers/subresources/scripts/methods/update/). +- `--pages` + - If you don't use a Wrangler config file with your Pages project (i.e. a Wrangler config file containing `pages_build_output_dir`), use this flag to force `wrangler check startup` to treat your project as a Pages project. From 79e0e8574da93856ea1b79e4ab083d00ad969f5b Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Mon, 7 Apr 2025 11:12:19 +0100 Subject: [PATCH 5/5] fix link --- src/content/docs/workers/platform/limits.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/platform/limits.mdx b/src/content/docs/workers/platform/limits.mdx index 92644977aee383e..8c138e8127f658c 100644 --- a/src/content/docs/workers/platform/limits.mdx +++ b/src/content/docs/workers/platform/limits.mdx @@ -272,7 +272,7 @@ You can measure your Worker's startup time by deploying it to Cloudflare using [ If you are having trouble staying under this limit, consider [profiling using DevTools](/workers/observability/dev-tools/) locally to learn how to optimize your code. -When you attempt to deploy a Worker using the [Wrangler CLI](/workers/wrangler/), but your deployment is rejected because your Worker exceeds the [maximum startup time](workers/platform/limits/#worker-startup-time), Wrangler will automatically generate a CPU profile that you can import into Chrome DevTools or open directly in VSCode. You can use this to learn what code in your Worker uses large amounts of CPU time at startup. Refer to [`wrangler check startup`](/workers/wrangler/commands/#startup) for more details. +When you attempt to deploy a Worker using the [Wrangler CLI](/workers/wrangler/), but your deployment is rejected because your Worker exceeds the maximum startup time, Wrangler will automatically generate a CPU profile that you can import into Chrome DevTools or open directly in VSCode. You can use this to learn what code in your Worker uses large amounts of CPU time at startup. Refer to [`wrangler check startup`](/workers/wrangler/commands/#startup) for more details.