Source maps and stack traces

Last updated Oct 23, 2026 help with debugging your code when your application encounters an unhandled exception. Stack traces show you the specific functions that were called, in what order, from which line and file, and with what arguments.

Most JavaScript code is first bundled, often transpiled, and then minified before being deployed to production. This process creates smaller bundles to optimize performance and converts code from TypeScript to Javascript if needed.

Source maps translate compiled and minified code back to the original code that you wrote. Source maps are combined with the stack trace returned by the JavaScript runtime to present you with a stack trace.

Caution

Support for uploading source maps for Pages is available now in open beta. Minimum required Wrangler version: 3.60.0.

Source Maps

To enable source maps, provide the --upload-source-maps flag to wrangler pages deploy or add the following to your Pages application's Wrangler configuration file if you are using the Pages build environment:

{
    "upload_source_maps": true
}
upload_source_maps = true

When uploading source maps is enabled, Wrangler will automatically generate and upload source map files when you run wrangler pages deploy.

Stack traces

​​ When your application throws an uncaught exception, we fetch the source map and use it to map the stack trace of the exception back to lines of your application’s original source code.

You can then view the stack trace when streaming real-time logs.

Note

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 ↗︎, you will not get a deobfuscated stack trace.

Limits

Description Limit
Maximum source map size, gzipped 15 MiB
Maximum source map size, encoded (uncompressed) 60 MiB

Was this helpful?

YesNo

On this page

Source maps and stack traces - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/pages/functions/source-maps/#page","headline":"Source maps and stack traces","description":"Adding source maps and generating stack traces for Pages.","url":"https://developers.cloudflare.com/pages/functions/source-maps/","inLanguage":"en","image":"https://developers.cloudflare.com/pages/functions/source-maps/og.png?v=c5ff4af544aeb116","dateModified":"2026-10-23","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Author Pages Functions in TypeScript and configure type generation with Wrangler. title: TypeScript image: https://developers.cloudflare.com/pages/functions/typescript/og.png?v=46eef2f745982dd6


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/pages/llms.txt
Use this file to discover all available pages before exploring further.