skip to content

Source Maps, Overrides, Console

Debugging shipped code needs source maps, trying a fix needs local overrides, and the Console's utilities shorten both. Interviewers use these to see if you can diagnose a production bundle.

on this pageshow

explore

questions

6

In the Chrome DevTools Sources panel, what changes once a source map loads for a minified bundle, and which code actually runs?

level: juniorimportance: must knowfreq 48%

answer

  1. two views, one running program
  2. the map is not executed
  3. Authored versus Deployed in the file tree
  4. breakpoints translate to shipped positions
  5. originals read-only without a workspace

basics

~20 s

Chrome still runs the minified bundle. A loaded source map only changes what DevTools shows: original files appear in Sources, and breakpoints, errors, logs and Call Stack frames are translated to original files and lines.

solid answer

~50 s

Chrome keeps executing the deployed, minified bundle; a source map changes only what DevTools displays. Once it loads, the original files appear in the Sources file tree, and **Group by authored/deployed** splits the tree into `Authored` and `Deployed` sections. You set a breakpoint on a line of an original file and DevTools resolves it to the matching position in the bundle, so execution pauses in shipped code while you read your own. Errors, logs and Call Stack frames are translated the same way, which is why a Console link opens the original file. The editor's status bar links back to the deployed file, and that file shows a `Source map loaded` notice. An original file from a map is read-only unless a workspace binds it to a folder on disk, since Chrome never loaded it as code. It is only accurate if the map belongs to that exact build.

go deeper

for a junior

Recall the one-line model: Chrome runs the bundle, and the Sources panel shows you the original through the map. Be able to find the original file and set a breakpoint in it.

for a middle

Explain what gets translated: breakpoints, Console links, stack frames. Mention Group by authored/deployed, and that original files stay read-only unless a workspace binds them to disk.

for a senior

Show you distrust the view when it matters. A map from another build gives wrong positions without any error, so you click through to the deployed file before believing what a pause shows.

for a principal

Connect the view to what the team can do in an incident: mapped debugging only helps if an engineer can get the map for the exact deployed build, so treat that access as a decision, not an accident.

## Two views of one running program A **minified bundle** is the file your build actually ships: many source files merged into one, with whitespace removed and names shortened. A **source map** is a companion file recording which position in that bundle came from which position in which original file. When Chrome DevTools loads one, nothing about execution changes. Chrome still parses and runs the **deployed** code exactly as it would for any visitor. What changes is the view: DevTools now holds a translation table and uses it wherever it shows you a location. So the honest summary is that Chrome runs your minified code while the Sources panel shows you the code you authored. How a build produces the map, and how the shipped file refers to it, is a separate subject. This answer starts from the moment the map is there. ## What appears in the Sources panel Once the map has loaded, several things look different: - **Original files in the file tree.** The files the map names are listed beside the deployed ones, and Quick Open can find them by name. - **Authored and Deployed groups.** The file tree's menu offers **Group by authored/deployed**, which sorts everything into an `Authored` section of original sources and a `Deployed` section of what the server sent. - **A notice on the deployed file.** Opening the bundle shows `Source map loaded`, with a pointer to where the associated files can be found. - **A link back.** While you read an original file, the editor's status bar links to the deployed file it came from, so you can always check what is really there. ## How debugging behaves on mapped code Here is the everyday flow on a page whose map loaded: 1. Open the original file from the `Authored` section or through Quick Open. 2. Set a breakpoint on a line you recognise. DevTools translates that line to a position in the bundle, and that position is where the pause really happens. 3. Trigger the code. Chrome pauses inside the deployed code, and the editor shows you the matching original line. 4. Read the **Call Stack** pane. It names the original file rather than the bundle. 5. Look at the Console. Errors and logs are mapped too, and the link beside a message opens the original file. The translation is what makes this feel like debugging your own source. It is still a translation: if you click through to the deployed file, the same pause is sitting in the shortened code. ## What a map does not change | Question | With a map loaded | Reason | |---|---|---| | Which code executes? | The deployed bundle | The map holds positions and names; it is not run | | Does the page behave differently? | No | A bug in the bundle stays a bug in the bundle | | Can you edit the original file? | Only through a workspace | Chrome never loaded it as a script | | Is the shipped file altered? | No | Only the DevTools display changes | ## Limits worth stating in an interview - **The map must match the build.** A map from a different build can still load without complaint, and its positions then point at the wrong statements. Breakpoints that land on odd lines are the classic symptom. - **Originals are read-only by default.** DevTools only lets you edit an original file from a map when a workspace has bound it to a folder on disk. Without that, the file is a view and nothing more. - **Pretty-printing is not a substitute.** DevTools automatically pretty-prints a deployed file that does not come from a map, which makes a minified file readable. That is reformatting only: the shortened names stay, and no original file appears. - **Settings can switch it off.** **JavaScript source maps** and **CSS source maps** are settings in the Sources section of DevTools Settings. With the JavaScript one off, you get no original files and no notice either, which can look like a missing map. - **The ignore list interacts with maps.** A script on the ignore list can show `Source map skipped for this file`, so a file you excluded from debugging may also stay unmapped. ## What to say if you only have a minute Lead with the model: the browser runs the bundle, and the map only changes how DevTools labels what it shows you. Then give one concrete consequence, such as a breakpoint set in an original file pausing at a translated position in shipped code. Finish with the read-only limit and the need for a map from the same build, because together they show that you understand the map as a lookup table and not as a second copy of the program.

  • A breakpoint set in an original file pauses on an unrelated statement. What do you suspect first?
    That the map does not belong to the deployed build. DevTools resolves original lines through the map's positions, so a map from another build loads fine and translates to the wrong place. Confirm by clicking through to the deployed file and reading what is really at the pause, then get the map produced by that exact build.
  • Does a pretty-printed bundle give you what a source map gives you?
    No. DevTools pretty-prints a deployed file automatically, but that only reformats the shipped text so you can read it. Shortened names stay shortened, there is no original file to open, and frames still name the bundle. It is the fallback when no map is available, not an equivalent.
  • Can you type a fix into an original TypeScript file shown through a map?
    Not by itself: DevTools treats an original file from a map as read-only unless a workspace has bound it to a folder on your disk. Without a local checkout, the alternative is a local override of the deployed file, which is the file Chrome actually loads.

Subtitles on a foreign film: the film plays unchanged and you read it in your own language. The wrong subtitle track still displays, but the words stop matching the scene, just as a map from another build points at the wrong statements.

  • With a source map loaded, Chrome executes the original TypeScript instead of the bundle.
  • A source map changes how the page behaves, so a bug can vanish once it loads.
  • Original files shown through a map can be edited and saved like any local file.
  • Pretty-printing a minified file is the same as having its source map.
  • A breakpoint in an original file only works if you repeat it in the bundle.
open as a page

In Chrome DevTools, a production stack frame still reads `checkout.4be1.js:1:90412` in the Console and Sources; how do you work out why no source map applied?

level: seniorimportance: must knowfreq 45%

basics

~20 s

Open the deployed file in Sources and read its notice: failed to load, skipped, or loaded. No notice points to the setting or a missing reference, where Add source map attaches one by URL. Wrong lines mean another build's map.

open as a page

In the Chrome DevTools Console, how do you inspect a button's listeners and events, and why can't those helpers ship in a page script?

level: middleimportance: should knowfreq 30%

basics

~10 s

Select the button in Elements, then use getEventListeners($0) for its registered listeners and monitorEvents($0, 'mouse') to log its events. These Console utilities work only from the Console, so a page script calling them fails.

open as a page

In Chrome DevTools, what does putting a script on the ignore list change about stepping, exceptions and stack traces, and what does it leave alone?

level: middleimportance: should knowfreq 33%

basics

~10 s

An ignored script still runs unchanged. The debugger skips stepping through it and won't stop on its exceptions, and its frames are hidden from the Call Stack pane until you check Show ignore-listed frames.

open as a page

In Chrome DevTools, how do you try a one-line fix for a production-only bug in a minified bundle when you have no local build?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Use local overrides: choose a folder, use Override content on the deployed bundle, edit, save and reload, and DevTools serves your copy. Source-mapped originals can't be overridden, so the edit goes into the minified file.

open as a page

In Chrome DevTools, when do you pin a Console live expression rather than save a Sources snippet, and what risk comes with each?

level: middleimportance: nice to knowfreq 20%

basics

~20 s

Pin a live expression to watch a value that keeps changing, because DevTools re-evaluates it about every 250 ms. Save a snippet for a script you rerun on demand. Live expressions repeat side effects; snippets are local and unsynced.

open as a page