skip to content

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%

answer

  1. serve a local copy across reloads
  2. pick a folder, then allow access
  3. the deployed file, not the original
  4. expect to edit raw minified text
  5. why not a workspace here

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.

solid answer

~50 s

I use local overrides, which need no build. In **Sources** > **Overrides** I select a folder and grant access, then right-click the deployed bundle and choose `Override content`. The map helps me read the original and find the logic, but a source-mapped file can't be overridden: DevTools says so and offers the deployed file instead. So the edit goes into the minified text, found by a nearby string literal, because the pretty-print toggle is hidden for editable JavaScript. I save and reload, and DevTools serves my copy rather than the network file. A workspace is wrong here since it saves edits into a local checkout I don't have. The fix proves itself only in my session, it runs against real data, and the edit can throw off later mapped columns. It also stops applying once a deploy renames the file, so the real change still goes through the build.

go deeper

for a junior

Recall that local overrides keep a change across reloads by serving a copy from a folder you chose. It affects only your own browser session.

for a middle

Explain the steps, and the difference from a workspace: an override writes a throwaway copy, and a workspace writes to your real source. Know that headers can be overridden too.

for a senior

Show the minified-code traps: the original can't be overridden, the edit goes into raw deployed text, later mapped columns can drift, and a renamed file ends it. Be careful about real data while testing.

for a principal

The tradeoff is speed of proof against discipline. An override confirms a hypothesis in minutes without touching production, so set the expectation that it is evidence for a fix and never a substitute for shipping one.

## The situation, and the tool for it A bug reproduces only on production. The code there is a **minified bundle**, you have no local build that shows the problem, and you want to know within minutes whether a one-line change fixes it. A change to the DOM or a value typed into the Console is lost on reload, and many bugs only show up during startup. You need a change that survives a page load, and Chrome DevTools has one: **local overrides**. When you save a change, DevTools writes a copy of the modified file into a folder you chose. When the page reloads, DevTools serves that local copy instead of the network resource. The server is untouched and no other visitor is affected. Overrides cover most file types as well as response headers, so you can prototype with no backend or deploy access. ## The steps 1. Open **Sources** > **Overrides** and use `Select folder for overrides`. Grant access when Chrome asks. The **Local overrides** checkbox in that tab turns the feature on and off. 2. Use the source map to read the original code and identify the logic to change. 3. Right-click the deployed bundle, in Sources or in the Network panel, and choose `Override content`. 4. Find the spot in the deployed text. Search for a string literal or property name near the logic, since those survive minification. 5. Make the smallest edit you can, save, and reload. 6. Confirm the overridden file is the one served, then test the behaviour. `Show all overrides` in the Network context menu takes you to the list. 7. Clear the **Local overrides** checkbox, or use `Clear configuration`, once you have your answer. ## The traps specific to minified code - **You can't override the original file.** Choosing `Override content` on a mapped file brings up a dialog saying it is a source mapped file and can't be overridden, and asking whether to override the deployed file instead. The map helps you read and locate; the edit goes into what Chrome really loads. - **Scripts become editable only in this mode.** A deployed script from the network can't be edited in Sources until overrides are active or a workspace binds it. Stylesheets are the exception. - **Expect raw text.** DevTools hides the pretty-print toggle for editable JavaScript, so plan to work on the minified line and find your place by searching. - **The map does not know about your edit.** A minified bundle is often one long line, so inserting characters shifts every later column on it. Mapped positions after your edit can drift, so judge the fix by behaviour and not by where a breakpoint lands. - **A hashed file name ends the experiment.** A deploy that renames `app.4be1.js` to `app.77ac.js` produces a different resource, so your override no longer applies to it. ## Local overrides versus workspaces | | Local overrides | Workspaces | |---|---|---| | Needs your source on disk | No | Yes | | Where a save goes | A copy in a folder for overrides | The real source file | | Works on a production URL | Yes | Built around a site served from your source | | Original file from a map | Can't be overridden | Editable once mapped through the workspace | | Response headers | Yes, through a `.headers` file | No | A **workspace** connects a folder of your project to the page, so a change made in DevTools lands in your source file. That is the right tool for day-to-day development with a checkout and a local server. Without a local build, it has nothing to bind to, which rules it out for this scenario. ## Headers and limits If the suspected fix is a response header rather than code, right-click the request in the Network panel and choose `Override headers`. DevTools opens an editor for the response headers, stores the rules in a `.headers` file listed under **Sources** > **Overrides**, and applies them on the next refresh. Two edits are not saved by overrides: changes to the DOM tree in the Elements panel, and changes in the Styles pane to CSS whose source is an HTML file. Edit the HTML file in Sources instead. ## Using the result responsibly An override proves the hypothesis on your machine and nothing more. Treat these as part of the job: - **Real data is at stake.** You are running modified code against production with your real session, so avoid exercising anything that writes until you are sure of the change. - **It is not a release.** No user receives the change. The real fix still goes through the source, the build and the normal delivery path. - **Clean up.** A forgotten override keeps serving stale code on your machine, and it can make a later bug report from you wrong.

  • Why can't you just override the TypeScript file the source map shows you?
    Chrome never loaded that file; it loaded the bundle. An override replaces a network resource with a local copy, so it only makes sense for what was actually fetched. DevTools says a source mapped file can't be overridden and offers the deployed file instead, so you read in the original and edit the deployed text.
  • When would a workspace be the better tool than an override?
    When you have the source on disk and are serving the site from it. A workspace binds that folder, so a DevTools edit lands in your real source file, and mapped originals become editable. Overrides suit the opposite case: code you can't rebuild, on a site you don't serve, where a throwaway copy is enough.
  • The suspected fix is a response header rather than code. What changes?
    The override still lives in the same folder, but you start in the Network panel: right-click the request and choose Override headers. DevTools opens the response headers editor and stores your rules in a .headers file under Sources, then Overrides. Refresh and they apply, with no server access.

  • To try a fix on production you must first rebuild and redeploy the bundle.
  • A source-mapped original file can be overridden directly, and DevTools recompiles it on reload.
  • A workspace is the way to patch a production site with no local checkout.
  • A local override reaches every visitor to the site until you clear it.
  • Edits to the DOM in the Elements panel persist across reloads once overrides are on.
  • Once an override works, it keeps applying after the next deploy renames the file.