slop audit
Blog post 19 / Browser checks

JavaScript console errors: pre-launch guide

Use this JavaScript console errors guide to find page exceptions and failed requests, debug them in DevTools, and add a focused Playwright check before launch.

By Slop Audit · 8 min read

JavaScript console errors can expose a broken production page before a visitor reports it. A page may render its headline while an exception stops the main action, an API request fails, or a blocked script removes part of the interface. Check the deployed URL, reproduce the page's main task, and keep the browser evidence with the release.

This guide covers errors that appear during page load and a short public interaction. It does not replace unit tests, authenticated end-to-end tests, or production error monitoring.

Classify JavaScript console errors before fixing them

The browser can report several signals in the Console and Network panels. Classify each signal before editing code because the same red row can point to a different failure layer.

  • Uncaught page exception: JavaScript threw an error that no code handled. Common examples include TypeError, ReferenceError, and rejected promises.
  • Application console error: Your code or a library called console.error(). The message may describe a handled failure, so read the surrounding state before deciding severity.
  • Failed network request: The browser could not receive an HTTP response because of a timeout, DNS error, blocked request, connection failure, or similar transport problem.
  • HTTP error response: The server returned a response such as 404, 401, 429, or 500. The request completed at the network layer, but the status still requires review.

MDN's JavaScript error reference lists built-in error types and their messages. Use the error name, message, file, line, and stack as the first debugging record.

Playwright makes an important distinction in its Page event documentation: requestfailed fires when the browser cannot get an HTTP response. A 404 or 503 response does not fire that event. Track response events when your release gate must catch HTTP status failures too.

Check browser console errors on the deployed page

Open the production URL in a clean browser profile. Preview deployments can use different API hosts, environment variables, content security policies, and asset paths.

  1. Open Chrome DevTools, then select Console.
  2. Clear old entries and reload the page with DevTools open.
  3. Open Network, enable Disable cache, and reload again.
  4. Complete the page's main public task, including navigation, forms, dialogs, or data loading that the visitor needs.
  5. Repeat the task at a narrow viewport and the supported desktop width.

Chrome's Console reference explains message levels, source filters, CORS entries, and log persistence. The Network panel reference shows request status, initiator, headers, response bodies, and failed-request reasons.

Save the exact message and stack rather than a cropped screenshot of the last line. Record the production URL, viewport, action, browser version, release identifier, and time. A useful issue gives another developer enough context to reproduce the error.

If a module script returns HTML or an incompatible content type, use the JavaScript MIME type error troubleshooting guide to trace the asset path, fallback rule, and deployed response.

Separate the first failure from follow-on noise

One missing configuration value can create a chain of errors. An API base URL becomes undefined, the fetch fails, a component reads absent response data, and an analytics call logs another error. Fixing the final stack trace first leaves the source failure in place.

Use this order:

  1. Find the earliest error from the current page load or interaction.
  2. Open its source location and inspect the full stack.
  3. Match network failures to their initiator and response details.
  4. Reproduce with extensions disabled and the cache cleared.
  5. Fix the owner of the first failure, deploy, and rerun the same steps.

Chrome's source map guide explains how DevTools maps deployed code to the source you wrote. Keep access to those maps within your team's debugging workflow when public delivery would expose source you do not intend to publish.

Triage first-party and third-party errors

Start with errors that belong to your origin, its subdomains, and inline page code. A failed first-party script, stylesheet, image, font, or API request can remove content or stop the main path.

Third-party failures still deserve an owner. Consent tools, payment providers, analytics scripts, and embedded media can affect a launch. Put each dependency into one of two groups:

  • The page needs the dependency for its main task. Treat the failure as a release blocker or provide a tested fallback.
  • The dependency supports an optional feature. Keep the page usable, then monitor the vendor and document the accepted failure.

Do not hide an error with a Console filter or a broad try...catch. Handle the failure where your code can give the user a safe state, and remove stray console.error() calls after the underlying problem has gone.

The website security headers checklist covers CSP and related response controls. Use it when the console reports a blocked script, connection, font, image, or frame.

If the page loads over HTTPS but requests an HTTP asset or API, follow the mixed content errors troubleshooting guide to repair the URL source and verify browser behavior.

Test JavaScript console errors with Playwright

A small Playwright check can fail a release when the tested path produces a page exception, an error-level console message, a transport failure, or an HTTP error response.

import { expect, test } from "@playwright/test";

test("public page has no runtime errors", async ({ page }) => {
  const issues: string[] = [];

  page.on("console", (message) => {
    if (message.type() === "error") {
      issues.push(`console: ${message.text()}`);
    }
  });

  page.on("pageerror", (error) => {
    issues.push(`pageerror: ${error.message}`);
  });

  page.on("requestfailed", (request) => {
    issues.push(
      `requestfailed: ${request.method()} ${request.url()} ${request.failure()?.errorText ?? "unknown"}`,
    );
  });

  page.on("response", (response) => {
    if (response.status() >= 400) {
      issues.push(`http: ${response.status()} ${response.url()}`);
    }
  });

  await page.goto("https://example.com/", { waitUntil: "load" });

  // Replace this assertion and action with the page's main public task.
  await expect(page.getByRole("heading", { level: 1 })).toBeVisible();

  expect(issues, issues.join("\n")).toEqual([]);
});

Attach listeners before navigation so the test captures startup errors. Add the interactions that trigger menus, forms, or lazy data. Run separate projects for the viewports and browsers you support.

Keep an allowlist narrow and reviewed. Match a known message plus its source URL instead of ignoring every error from a domain. Remove an allowlist entry after the dependency or application fix ships.

Playwright's debugging guide shows how Trace Viewer connects actions with console messages, network requests, and DOM snapshots. Retain the trace on failure so the CI result includes more than an error count.

Turn the evidence into a release task

Write a ticket with the observed signal, user impact, owner, and retest step. For example:

The pricing page throws TypeError: plans.map is not a function after the production plans request returns 500 at the mobile and desktop viewports. Fix the response handling, show a useful error state, and rerun the public pricing path.

Link the ticket to the release or commit that introduced the change. The website audit report example provides a compact evidence-to-fix format. The broken link guide covers 404 pages and same-origin destinations that a requestfailed listener will miss.

Add the finished check to your website regression testing routine. A stable test should reproduce a user path and name the failed request or exception. A raw count such as “three console errors” leaves the reviewer guessing.

Check JavaScript console errors with Slop Audit

Run Slop Audit against the public URL you plan to ship. During its mobile and desktop Browser Run, Slop Audit records error-level console messages, uncaught page errors, and failed same-site requests. The report includes a bounded message and source URL as reviewable evidence.

Slop Audit checks the submitted public page during load. It does not sign in, click every control, cover every route, or replace client-side error monitoring. Its runtime findings also exclude third-party source URLs and do not treat an HTTP error response as a requestfailed event. Use your Playwright response listener, API tests, and the website launch checklist to cover those gaps.

JavaScript console errors release checklist

  • Test the production URL with Console and Network open.
  • Reload with cache disabled, then complete the main public task.
  • Record page exceptions, error-level messages, failed requests, and HTTP error responses as separate signals.
  • Fix the earliest owned failure before its follow-on errors.
  • Test mobile and desktop viewports with a reviewed first-party boundary.
  • Add Playwright listeners before navigation and retain traces on failure.
  • Deploy the fix and rerun the same URL, viewport, and action.