Skip to content

Commit a775c8d

Browse files
committed
[workers-observability] add examples for source maps in changelog and documentation
1 parent 7478711 commit a775c8d

File tree

6 files changed

+53
-26
lines changed

6 files changed

+53
-26
lines changed
64.3 KB
Loading
53.8 KB
Loading

src/content/changelog/workers/2025-02-25-gzip-source-maps.mdx

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

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ When `upload_source_maps` is set to `true`, Wrangler will automatically generate
3535

3636
:::note
3737

38-
3938
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).
4039

41-
4240
:::
4341

4442
## Stack traces
@@ -64,6 +62,25 @@ When Cloudflare attempts to remap a stack trace to the Worker's source map, it d
6462
| ------------------------------ | ------------- |
6563
| Maximum Source Map Size | 15 MB gzipped |
6664

65+
## Example
66+
67+
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.
68+
69+
<FileTree>
70+
- wrangler.jsonc
71+
- tsconfig.json
72+
- src
73+
- calculator.ts
74+
- index.ts
75+
</FileTree>
76+
77+
Let's see how source maps can simplify debugging an error in the ComplexCalculator class.
78+
79+
![Stack Trace without Source Map remapping](~/assets/images/workers-observability/without-source-map.png)
80+
**No Source Map 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`.
81+
82+
![Stack Trace with Source Map remapping](~/assets/images/workers-observability/with-source-map.png)
83+
**With Source Map uploaded**: all methods reference the correct files and line numbers.
6784

6885
## Related resources
6986

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)