Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/content/changelog/workers/2025-03-25-gzip-source-maps.mdx
Original file line number Diff line number Diff line change
@@ -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:

<WranglerConfig>
```toml
upload_source_maps = true
```
</WranglerConfig>
10 changes: 6 additions & 4 deletions src/content/docs/pages/functions/source-maps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

---

Expand Down Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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 day<sup>1</sup> | 5 Billion |
Expand Down
36 changes: 30 additions & 6 deletions src/content/docs/workers/observability/source-maps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

<Render file="source-maps" product="workers" />

Expand Down Expand Up @@ -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
Expand All @@ -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.

<FileTree>
- wrangler.jsonc
- tsconfig.json
- src
- calculator.ts
- index.ts
</FileTree>

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.
Expand Down
2 changes: 1 addition & 1 deletion src/content/partials/workers/workers_logs_pricing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <br /> +$0.60 per additional million | 7 Days |
Loading