diff --git a/src/assets/images/workers-observability/with-source-map.png b/src/assets/images/workers-observability/with-source-map.png new file mode 100644 index 000000000000000..7ac4795b6f972f6 Binary files /dev/null and b/src/assets/images/workers-observability/with-source-map.png differ diff --git a/src/assets/images/workers-observability/without-source-map.png b/src/assets/images/workers-observability/without-source-map.png new file mode 100644 index 000000000000000..ed3b3f412328df4 Binary files /dev/null and b/src/assets/images/workers-observability/without-source-map.png differ diff --git a/src/content/changelog/workers/2025-03-25-gzip-source-maps.mdx b/src/content/changelog/workers/2025-03-25-gzip-source-maps.mdx new file mode 100644 index 000000000000000..4e332701cc49461 --- /dev/null +++ b/src/content/changelog/workers/2025-03-25-gzip-source-maps.mdx @@ -0,0 +1,37 @@ +--- +title: Source Maps are Generally Available +description: Source maps are now Generally Available with a larger maximum size limit +products: + - workers +date: 2025-03-25T00:00:00Z +--- + +import { WranglerConfig } from "~/components"; + +Source maps are now Generally Available (GA). You can now be uploaded with a maximum gzipped size of 15 MB. +Previously, the maximum size limit was 15 MB uncompressed. + +Source maps help map between the original source code and the transformed/minified code that gets deployed +to production. By uploading your source map, you allow Cloudflare to map the stack trace from exceptions + onto the original source code making it easier to debug. + +![Stack Trace without Source Map remapping](src/assets/images/workers-observability/without-source-map.png) + +With **no source maps uploaded**: notice how all the Javascript has been minified to one file, so the stack trace is missing information on file name, shows incorrect line numbers, and incorrectly references `js` instead of `ts`. + +![Stack Trace with Source Map remapping](src/assets/images/workers-observability/with-source-map.png) + +With **source maps uploaded**: all methods reference the correct files and line numbers. + +Uploading source maps and stack trace remapping happens out of band from the Worker execution, +so source maps do not affect upload speed, bundle size, or cold starts. The remapped stack +traces are accessible through Tail Workers, Workers Logs, and Workers Logpush. + +To enable source maps, add the following to your +[Pages Function's](/pages/functions/source-maps/) or [Worker's](/workers/observability/source-maps/) wrangler configuration: + + +```toml +upload_source_maps = true +``` + diff --git a/src/content/docs/pages/functions/source-maps.mdx b/src/content/docs/pages/functions/source-maps.mdx index 50e442fe032d0e5..dd6504131d61790 100644 --- a/src/content/docs/pages/functions/source-maps.mdx +++ b/src/content/docs/pages/functions/source-maps.mdx @@ -3,9 +3,6 @@ pcx_content_type: configuration title: Source maps and stack traces head: [] description: Adding source maps and generating stack traces for Pages. -sidebar: - badge: - text: Beta --- @@ -47,9 +44,14 @@ You can then view the stack trace when streaming [real-time logs](/pages/functio The source map is retrieved after your Pages Function invocation completes — it's an asynchronous process that does not impact your applications's CPU utilization or performance. Source maps are not accessible inside the application at runtime, if you `console.log()` the [stack property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack), you will not get a deobfuscated stack trace. - ::: +## Limits + +| Description | Limit | +| ------------------------------ | ------------- | +| Maximum Source Map Size | 15 MB gzipped | + ## Related resources * [Real-time logs](/pages/functions/debugging-and-logging/) - Learn how to capture Pages logs in real-time. diff --git a/src/content/docs/workers/observability/logs/workers-logs.mdx b/src/content/docs/workers/observability/logs/workers-logs.mdx index e4e4e9e4107ac96..5f7abbb6740d36a 100644 --- a/src/content/docs/workers/observability/logs/workers-logs.mdx +++ b/src/content/docs/workers/observability/logs/workers-logs.mdx @@ -187,7 +187,7 @@ head_sampling_rate = 0.01 # 1% sampling rate ## Limits -| Description | Retention | +| Description | Limit | | ------------------------------------------------------------------ | ---------- | | Maximum log retention period | 7 Days | | Maximum logs per account per day1 | 5 Billion | diff --git a/src/content/docs/workers/observability/source-maps.mdx b/src/content/docs/workers/observability/source-maps.mdx index 60ed84a6c411495..436beec6684d12d 100644 --- a/src/content/docs/workers/observability/source-maps.mdx +++ b/src/content/docs/workers/observability/source-maps.mdx @@ -3,13 +3,11 @@ pcx_content_type: configuration title: Source maps and stack traces head: [] description: Adding source maps and generating stack traces for Workers. -sidebar: - badge: - text: Beta --- -import { Render, WranglerConfig } from "~/components" +import { Render, WranglerConfig } from "~/components"; +import { FileTree } from "@astrojs/starlight/components"; @@ -38,10 +36,8 @@ When `upload_source_maps` is set to `true`, Wrangler will automatically generate :::note - Miniflare can also [output source maps](https://miniflare.dev/developing/source-maps) for use in local development or [testing](/workers/testing/integration-testing/#miniflares-api). - ::: ## Stack traces @@ -61,6 +57,34 @@ The source map is retrieved after your Worker invocation completes — it's an a When Cloudflare attempts to remap a stack trace to the Worker's source map, it does so line-by-line, remapping as much as possible. If a line of the stack trace cannot be remapped for any reason, Cloudflare will leave that line of the stack trace unchanged, and continue to the next line of the stack trace. +## Limits + +| Description | Limit | +| ------------------------------ | ------------- | +| Maximum Source Map Size | 15 MB gzipped | + +## Example + +Consider a simple project. `src/index.ts` serves as the entrypoint of the application and `src/calculator.ts` defines a ComplexCalculator class that supports basic arithmetic. + + +- wrangler.jsonc +- tsconfig.json +- src + - calculator.ts + - index.ts + + +Let's see how source maps can simplify debugging an error in the ComplexCalculator class. + +![Stack Trace without Source Map remapping](~/assets/images/workers-observability/without-source-map.png) + +With **no source maps uploaded**: notice how all the Javascript has been minified to one file, so the stack trace is missing information on file name, shows incorrect line numbers, and incorrectly references `js` instead of `ts`. + +![Stack Trace with Source Map remapping](~/assets/images/workers-observability/with-source-map.png) + +With **source maps uploaded**: all methods reference the correct files and line numbers. + ## Related resources * [Tail Workers](/workers/observability/logs/logpush/) - Learn how to attach Tail Workers to transform your logs and send them to HTTP endpoints. diff --git a/src/content/partials/workers/workers_logs_pricing.mdx b/src/content/partials/workers/workers_logs_pricing.mdx index 0fe88ec3290374f..8772eec1debdf90 100644 --- a/src/content/partials/workers/workers_logs_pricing.mdx +++ b/src/content/partials/workers/workers_logs_pricing.mdx @@ -9,5 +9,5 @@ Workers Logs is included in both the Free and Paid [Workers plans](/workers/plat | | Log Events Written | Retention | | ------------------ | ------------------------------------------------------------------ | ---------- | -| **Workers Free** | 200,000 per day | 7 Days | +| **Workers Free** | 200,000 per day | 3 Days | | **Workers Paid** | 20 million included per month
+$0.60 per additional million | 7 Days |