DEV Community

Jianzhujisuan
Jianzhujisuan

Posted on

My checker couldn't start a browser, so it logged a notice and exited 0

For forty-three days my morning health check ended with one line:

巡检结论:全正常(提醒 2 项);待处理留言 0 条
Enter fullscreen mode Exit fullscreen mode

"All normal, 2 notices." I read that line, closed the terminal, and got on with the day.

On the morning of December 5 it would have printed almost the same thing — while the only check in the entire suite that opens a real browser had executed zero of its 22 assertions. Not failed. Not skipped loudly. Just quietly not run, inside the bucket called "notice".

This post is about that bucket. The browser is incidental.

What actually broke

The check shells out to a Node script that drives Playwright against production: root redirect chain, card count matching the sitemap, keyboard focus order, a form submission, console errors. To do any of that it needs a node.exe, and I had written the path as a literal string pointing into a versioned directory:

NODE = r"C:\Users\...\binaries\node\versions\22.22.2-6\node.exe"
Enter fullscreen mode Exit fullscreen mode

That directory is created per release by the toolchain manager. When Node moved to 22.23.4-6, the old directory was removed, and my string became a path to nothing.

The checker handled it — that's the problem:

def run_ui(full=False):
    if not os.path.exists(NODE):
        add("browser e2e", False, f"no node at {NODE}", "warn")
        return False
Enter fullscreen mode Exit fullscreen mode

add() takes a level. fatal marks the run as failed and exits 1. warn prints [WARN], adds a row to the report, and leaves the exit code at 0.

A missing binary — a precondition, not a test result — was filed as a soft degradation.

Three outcomes, two buckets

Every check I run can end in exactly three states, and I had modelled two:

class Outcome(str, Enum):
    PASSED  = "passed"    # ran, and agreed
    FAILED  = "failed"    # ran, and disagreed
    SKIPPED = "skipped"   # never ran: precondition missing
Enter fullscreen mode Exit fullscreen mode

SKIPPED is not a softer FAILED. They point at different people. FAILED says the site is wrong — go look at the site. SKIPPED says the checker is wrong — go look at the checker, and assume the site is unverified until you do.

My code did exactly that: a False from os.path.exists() produced a yellow row and a green build.

Why nobody would have noticed anyway

I went back and parsed all 43 daily reports on disk, 2026-10-24 through 2026-12-05: 1,773 check rows across 62 distinct checks.

Result Rows
passed 1,723
notice 47
failed 3

Then I broke the 47 notices down by check name:

Check Notices
slow request, bare URL 22
slow request, versioned URL 21
deployed version ≠ local build 4

Forty-three of forty-seven were the same two latency checks crossing a 5-second threshold. And on 26 of the 43 days, the conclusion line read "all normal" while at least one notice was sitting in the report.

So the notice channel was already ~91% noise before the browser suite fell into it. Worse, when I counted the code: 27 of 49 add() call sites — 55.1% — are registered at notice level. More than half the suite is structurally incapable of failing the run.

That's the generalisable part: a severity level that has never blocked anything is a log file with extra steps. Once a channel is 91% noise, a real signal placed in it isn't quieter — it's absent, and reading that channel every morning is what trained me to stop reading it.

My severity was inverted

Three times in those 43 days the browser suite did run, and one assertion failed — 2026-11-04, 12-03, 12-04, each reporting passed 21 / failed 1. Those rows were marked failed, and the run exited 1. On the day the suite could not start at all, the same check produced a notice and the run exited 0.

So the checker shouted about 1 broken assertion out of 22 and whispered about 0 out of 22.

I reproduced the branch afterwards by pointing the variable at a directory that doesn't exist:

$ python _daily.py --ui
[WARN] 真浏览器端到端  找不到 node:...\_no_such_node\node.exe
巡检结论:全正常(提醒 1 项);待处理留言 0 条
$ echo $?
0
Enter fullscreen mode Exit fullscreen mode

Exit code 0. One yellow row. Twenty-two assertions executed: none. The report contains | browser e2e | notice | no node at ... | and a conclusion of 正常,提醒 1 项 — "normal, 1 notice". If I hadn't been staring at the log line, that is the entire evidence I would have had.

The wrapper would also have accepted zero assertions

While I was in there I found a second hole in the same ten lines. The wrapper parses the child's summary and trusts it:

m = re.search(r"通过\s*(\d+)\s*/\s*失败\s*(\d+)", out)
detail = f"passed {m.group(1)} / failed {m.group(2)}" if m else ""
add("browser e2e", p.returncode == 0, detail)
Enter fullscreen mode Exit fullscreen mode

If the child prints passed 0 / failed 0 and exits 0, that is a pass. There is no comparison against an expected count anywhere. A runner that discovers zero tests and reports success is the oldest failure in CI, and I had rebuilt it in forty lines of Python: the file contains 28 ok(...) call sites, the last healthy run reported 22 assertions, and nothing in the wrapper would have noticed the difference between 22 and 0.

The fix is a floor, not a flag:

EXPECTED_MIN = 22
ran = int(m.group(1)) + int(m.group(2))
if ran < EXPECTED_MIN:
    add("browser e2e", False, f"ran {ran} of {EXPECTED_MIN}", "fatal")
Enter fullscreen mode Exit fullscreen mode

Now "ran nothing" and "ran everything and liked it" are distinguishable states, which they were not before.

Fix the discovery, then fix the classification

Two separate defects, and fixing only the first would have left the second armed.

Discovery: instead of a pinned path, take the highest installed version by numeric key.

def find_node():
    p = os.environ.get("KB_NODE")
    if p and os.path.exists(p):
        return p
    root = r"C:\...\binaries\node\versions"
    cands = []
    for d in os.listdir(root):
        exe = os.path.join(root, d, "node.exe")
        if os.path.exists(exe):
            key = [int(x) if x.isdigit() else 0
                   for x in re.split(r"[^0-9]+", d) if x]
            cands.append((key, exe))
    return sorted(cands)[-1][1] if cands else ""
Enter fullscreen mode Exit fullscreen mode

The numeric key matters: as strings, 9.20.0 sorts after 22.23.4, so the naive version silently picks an ancient runtime the first time a single-digit major appears.

I left a hole in my own fix — the same mistake in miniature. The function originally ended with:

    return os.path.join(root, "22.22.2-6", "node.exe")
Enter fullscreen mode Exit fullscreen mode

The version that no longer exists. os.path.exists() on that path is False on this machine right now. If the directory listing ever throws, the resolver hands back a plausible-looking path to nothing and the check slides back into the notice branch, with a message that looks deliberate. A resolver must return empty and let the caller fail loudly; inventing a path is worse than admitting it doesn't know.

The cheapest fix, which I'd skipped: this box has a versions/current maintained by the toolchain manager. Pointing at that symlink would have survived the upgrade with no code at all. Version-pinned paths are only safe if something tests the pin — mine was pinned by a string and tested by nobody.

Classification, which is the part that generalises:

def run_ui(full=False):
    if not node:
        add("browser e2e", False, "node not found — suite did not run", "fatal")
        return
Enter fullscreen mode Exit fullscreen mode

Missing precondition is fatal. Slow response stays a notice, because it's genuinely a degradation. The rule I now apply to every check in the file: if this row can be yellow forever without anyone acting, it isn't a check, it's decoration. Of the 27 notice-level call sites, only the latency and version-drift ones survive that question.

Reproduce it in a minute

Find the one external binary your checker shells out to, point its path or env var at something that doesn't exist, run the checker, and read the exit code rather than the log.

If it exits 0, your green light means "nothing was verified" — and you'll find that out the day the thing you were verifying breaks. If it exits 1 but prints a line nobody reads, you have the same problem with better manners.

Checklist

  • Three outcomes, not two. passed / failed / skipped. Skipped is red, and names the missing precondition.
  • Audit the notice bucket. Has this level ever blocked anything? If not, it's a log. Mine was 55.1% of the suite.
  • Assertion floor. Compare assertions that ran against an expected minimum. Zero is not a pass.
  • No absolute paths into versioned directories. Resolve at runtime, return empty rather than guess.
  • Reproduce the missing-precondition branch on purpose, and read the exit code.

The site underneath all this is jianzhujisuan.com — a couple of hundred construction-material calculators served as static HTML, boring on purpose. What isn't fine is a monitor that says "all normal" because it never got out of bed.

Top comments (1)

Collapse
 
kashif_manzer profile image
Kashif Manzer •

The floor idea is good, but a count alone can still hide a swap. If one real test is removed and a trivial one is added, the total stays at 22 and the run still looks healthy. Comparing the actual names that ran against an expected list, or at least failing on any new skipped reason, catches that case. It also turns a new notice type into a signal instead of letting it blend into the old noise.