Skip to content

Fix/bug/header4#3877

Open
TonyKing0504 wants to merge 15 commits intotangly1024:mainfrom
TonyKing0504:fix/bug/header4
Open

Fix/bug/header4#3877
TonyKing0504 wants to merge 15 commits intotangly1024:mainfrom
TonyKing0504:fix/bug/header4

Conversation

@TonyKing0504
Copy link
Copy Markdown

Summary

  • Fix client-side hydration crash caused by header_4 block type in Notion's Table of Contents generation (getPageTableOfContents.js). The indentLevels map didn't include header_4, causing a stack underflow → destructure crash → React error boundary showing 404.
  • Upgrade react-notion-x from 7.7.1 to 7.10.0 to add native header_4 block rendering support.
  • Add undefined guard in TOC header type check to prevent similar crashes from any future unknown header types.

Root Cause

getPageTableOfContents.js matched header_4 via type.indexOf('header') >= 0 but indentLevels['header_4'] returned undefined. This caused the indent adjustment loop to repeatedly pop the stack until empty, then crash on indentLevelStack[-1] destructure.

Changes

File Change
lib/db/notion/getPageTableOfContents.js Added header_4: 3 to indentLevels map; added && indentLevels[type] !== undefined guard
package.json Upgraded react-notion-x 7.7.1 → 7.10.0 and related packages
yarn.lock Updated lockfile for new dependency versions

Test Plan

  • Verified on Vercel Preview deployment — article page renders fully (title, SQL toggle, share buttons, comments)
  • Verified on Production (www.dundun0504.com/article/data-analysis-prep) — page loads with no console errors
  • Confirmed no regression on other pages (sidebar, navigation, footer all render correctly)
  • Production branch set to main; deploy used as experimental branch

TonyKing0504 and others added 15 commits June 4, 2024 10:19
update name and some descriptions
change the web icon
add contact methods
Delete the .env.example file that provided commented environment variable examples and documentation (Next.js/Notion settings, analytics, comment systems, theme and UI options, etc.). Removes the sample env template from the repository to avoid tracking local configuration.
Replace the previous comma-separated NOTION_PAGE_ID value with a single Notion page ID ('73e215be006e466e9c36442b39670776') so the blog points to the updated Notion source for content.
Introduce UUID_REDIRECT in blog.config.js to enable redirecting UUID-based article paths to slug-based paths (relies on build-generated /public/redirect.json). The flag is controlled via NEXT_PUBLIC_UUID_REDIRECT and defaults to false. Also normalize EOF newline in the file.
Enable the theme switch in the floating widget (widget.config.js) and remove the duplicate THEME_SWITCH entry from blog.config.js. Update the GREETING_WORDS default with new welcome phrases and remove duplicate/unused entries (CUSTOM_MENU, BEI_AN) while tidying a contact.config comment. Also pin the Node engine in package.json to 20.x for consistent runtime.
Fixes client-side crash on articles containing Notion H4 headings
(header_4 block type) which were unsupported in v7.7.1.
Ensures Vercel installs the correct version from the lockfile.
The getPageTableOfContents function crashed when encountering Notion's
header_4 block type because indentLevels only mapped header, sub_header,
and sub_sub_header. The header_4 type matched the indexOf('header') check
but returned undefined for indentLevel, causing the indent stack to empty
and crash with "Cannot destructure property 'actual' of undefined".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

@TonyKing0504 is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant