Skip to content

Commit faa9207

Browse files
authored
t[workers-observability] Add changelog entry for source maps GA (#20289)
* [workers-observability] Add changelog entry for source maps GA * [workers-observability] add examples for source maps in changelog and documentation * [workers-observability] fix build errors * [workers-observability] update formatting --------- Co-authored-by: Rohin Lohe <[email protected]>
1 parent 7adb207 commit faa9207

File tree

7 files changed

+75
-12
lines changed

7 files changed

+75
-12
lines changed
64.3 KB
Loading
53.8 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Source Maps are Generally Available
3+
description: Source maps are now Generally Available with a larger maximum size limit
4+
products:
5+
- workers
6+
date: 2025-03-25T00:00:00Z
7+
---
8+
9+
import { WranglerConfig } from "~/components";
10+
11+
Source maps are now Generally Available (GA). You can now be uploaded with a maximum gzipped size of 15 MB.
12+
Previously, the maximum size limit was 15 MB uncompressed.
13+
14+
Source maps help map between the original source code and the transformed/minified code that gets deployed
15+
to production. By uploading your source map, you allow Cloudflare to map the stack trace from exceptions
16+
onto the original source code making it easier to debug.
17+
18+
![Stack Trace without Source Map remapping](src/assets/images/workers-observability/without-source-map.png)
19+
20+
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`.
21+
22+
![Stack Trace with Source Map remapping](src/assets/images/workers-observability/with-source-map.png)
23+
24+
With **source maps uploaded**: all methods reference the correct files and line numbers.
25+
26+
Uploading source maps and stack trace remapping happens out of band from the Worker execution,
27+
so source maps do not affect upload speed, bundle size, or cold starts. The remapped stack
28+
traces are accessible through Tail Workers, Workers Logs, and Workers Logpush.
29+
30+
To enable source maps, add the following to your
31+
[Pages Function's](/pages/functions/source-maps/) or [Worker's](/workers/observability/source-maps/) wrangler configuration:
32+
33+
<WranglerConfig>
34+
```toml
35+
upload_source_maps = true
36+
```
37+
</WranglerConfig>

src/content/docs/pages/functions/source-maps.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ pcx_content_type: configuration
33
title: Source maps and stack traces
44
head: []
55
description: Adding source maps and generating stack traces for Pages.
6-
sidebar:
7-
badge:
8-
text: Beta
96

107
---
118

@@ -47,9 +44,14 @@ You can then view the stack trace when streaming [real-time logs](/pages/functio
4744

4845
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.
4946

50-
5147
:::
5248

49+
## Limits
50+
51+
| Description | Limit |
52+
| ------------------------------ | ------------- |
53+
| Maximum Source Map Size | 15 MB gzipped |
54+
5355
## Related resources
5456

5557
* [Real-time logs](/pages/functions/debugging-and-logging/) - Learn how to capture Pages logs in real-time.

src/content/docs/workers/observability/logs/workers-logs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ head_sampling_rate = 0.01 # 1% sampling rate
187187

188188
## Limits
189189

190-
| Description | Retention |
190+
| Description | Limit |
191191
| ------------------------------------------------------------------ | ---------- |
192192
| Maximum log retention period | 7 Days |
193193
| Maximum logs per account per day<sup>1</sup> | 5 Billion |

src/content/docs/workers/observability/source-maps.mdx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ pcx_content_type: configuration
33
title: Source maps and stack traces
44
head: []
55
description: Adding source maps and generating stack traces for Workers.
6-
sidebar:
7-
badge:
8-
text: Beta
96

107
---
118

12-
import { Render, WranglerConfig } from "~/components"
9+
import { Render, WranglerConfig } from "~/components";
10+
import { FileTree } from "@astrojs/starlight/components";
1311

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

@@ -38,10 +36,8 @@ When `upload_source_maps` is set to `true`, Wrangler will automatically generate
3836

3937
:::note
4038

41-
4239
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).
4340

44-
4541
:::
4642

4743
## Stack traces
@@ -61,6 +57,34 @@ The source map is retrieved after your Worker invocation completes — it's an a
6157

6258
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.
6359

60+
## Limits
61+
62+
| Description | Limit |
63+
| ------------------------------ | ------------- |
64+
| Maximum Source Map Size | 15 MB gzipped |
65+
66+
## Example
67+
68+
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.
69+
70+
<FileTree>
71+
- wrangler.jsonc
72+
- tsconfig.json
73+
- src
74+
- calculator.ts
75+
- index.ts
76+
</FileTree>
77+
78+
Let's see how source maps can simplify debugging an error in the ComplexCalculator class.
79+
80+
![Stack Trace without Source Map remapping](~/assets/images/workers-observability/without-source-map.png)
81+
82+
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`.
83+
84+
![Stack Trace with Source Map remapping](~/assets/images/workers-observability/with-source-map.png)
85+
86+
With **source maps uploaded**: all methods reference the correct files and line numbers.
87+
6488
## Related resources
6589

6690
* [Tail Workers](/workers/observability/logs/logpush/) - Learn how to attach Tail Workers to transform your logs and send them to HTTP endpoints.

src/content/partials/workers/workers_logs_pricing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Workers Logs is included in both the Free and Paid [Workers plans](/workers/plat
99

1010
| | Log Events Written | Retention |
1111
| ------------------ | ------------------------------------------------------------------ | ---------- |
12-
| **Workers Free** | 200,000 per day | 7 Days |
12+
| **Workers Free** | 200,000 per day | 3 Days |
1313
| **Workers Paid** | 20 million included per month <br /> +$0.60 per additional million | 7 Days |

0 commit comments

Comments
 (0)