Skip to content

v1.9.4: fix Changelog view crashing on Windows (CRLF) checkouts - #8

Merged
gitluis merged 1 commit into
masterfrom
fix-changelog-crlf
Oct 25, 2026
Merged

gitluis merged 1 commit into
masterfrom
fix-changelog-crlf

Conversation

@gitluis

@gitluis gitluis commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #7 (fix-folder-permission). Merge #3 → #4 → #5 → #7 first, then this one. Released as v1.9.4 (bug fix, patch bump).

The bug

On Windows, the console showed this at startup:

Uncaught TypeError: Cannot read properties of null (reading '1')    views-db.js:734

Luis found it while testing #3 in Edge. It was already on master.

Cause

  • How the changelog is stored: views-db.js embeds the developer Changelog's text inside a block comment and reads it back with Function.toString().
  • The regex: /\/\*\n([\s\S]*)\n\*\// expects \n line endings.
  • Windows checkouts: Git for Windows checks files out with \r\n (core.autocrlf=true is its default). toString() returns the source exactly as written, so match() returned null and [1] threw.
  • Effect: the throw stopped views-db.js partway through loading, so the changelog view was never registered. Nothing else was affected: it's a developer-only view, and each script loads separately.

Fix

  • Normalize line endings first: .replace(/\r\n?/g, '\n') runs before the match.
  • No more throw: ?.[1] ?? '…could not be read' shows a message if the text can't be read.

How it was tested

Headless Chromium:

Checkout Result
LF (this branch) View registered, 15 versions rendered, no errors
CRLF (this branch, every .js/.html converted) Same, and no \r left in the text
CRLF (before the fix) Reproduces the crash, and the view is missing

The all-views smoke test (23 views and 6 Settings tabs, light and dark) also passes.

Not changed

The embedded changelog copy stops at v1.4.1, while CHANGELOG.md is current. Keeping the two in sync would be a separate change.

To check

  • In your Windows clone, reload FinLens. The red TypeError should be gone. In DevTools, showView('changelog') should open the Changelog view.

Generated by Claude Code

views-db.js embeds the changelog in a block comment and reads it back with
Function.toString() plus a regex expecting \n. Git for Windows checks files
out with \r\n, so match() returned null and [1] threw at load:
"Cannot read properties of null (reading '1')" at views-db.js:734. The
rest of views-db.js never ran, so the changelog view wasn't registered.

Normalize line endings before matching, and fall back to a message instead
of throwing. Found during Luis's manual test of #3 in Edge. Pre-existing
on master.

Tested headless: LF and CRLF checkouts both register the view and render
15 versions with no errors; the unfixed CRLF copy still reproduces the
crash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QoR1wxcaDjVVk3xmd5rRCt
@gitluis

gitluis commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Tested on Windows (Edge): passes

Tested at 5f3c8b5 in my Windows clone: Git for Windows with core.autocrlf=true, and js/views-db.js checked out with CRLF line endings (git ls-files --eol shows w/crlf). Opened index.html from file:// in Edge.

Check master (v1.9.3) fix-changelog-crlf (v1.9.4)
Startup console Uncaught TypeError: Cannot read properties of null (reading '1') at views-db.js:734 No errors
typeof VIEWS.changelog "undefined" "object"
CHANGELOG_MD.includes('\r') (not reached) false
## headings in CHANGELOG_MD (not reached) 15
showView('changelog') (not reached) Changelog view opens, with 15 version links and the rendered history
showView('db-inspector'), showView('db-schema') (not tested) Both open with no new errors; DB Inspector shows 257 records found (257 total in store) with the sample data
Version strings v1.9.3 v1.9.4 in the sidebar footer and in Settings → General

Line endings: the clone checks files out as CRLF. js/views-db.js is w/crlf on this branch, and the crash reproducing on master shows the same there.

1-crlf-check 3-branch-checkout-crlf

Before (master): the crash reproduces, and the view isn't registered.

2-master-typeerror

After (this branch): the console is clean at startup.

4-branch-clean-console

Changelog view:

5-changelog-view-console 6-changelog-view-scrolled

Other views in views-db.js: both open with no new errors.

7-db-inspector-samples 8-db-schema-samples

Notes

  • The Changelog checks were run in an InPrivate window, where storage starts empty (0 transactions). The DB Inspector and DB Schema checks were run in a normal window loaded with the three samples/ CSVs (257 transactions).
  • These console messages are unrelated to this PR:
  • The embedded changelog ends at v1.4.1, as the PR's "Not changed" section says. Syncing it with CHANGELOG.md can be a separate change.

The "To check" item is done. Approved for merge at 5f3c8b5.

@gitluis
gitluis merged commit 2b89fb3 into master Oct 25, 2026
@gitluis
gitluis deleted the fix-changelog-crlf branch October 25, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants