Skip to content

Fix /x/worker/ page broken by generic type params in MDX#1142

Merged
taras merged 1 commit intov4from
fix/escape-generic-type-params-in-mdx
Apr 5, 2026
Merged

Fix /x/worker/ page broken by generic type params in MDX#1142
taras merged 1 commit intov4from
fix/escape-generic-type-params-in-mdx

Conversation

@taras
Copy link
Copy Markdown
Member

@taras taras commented Mar 22, 2026

Summary

  • The /x/worker/ page was failing with "Failed to load worker due to error" because MDX interpreted generic type references like Result<T> in JSDoc comments as JSX tags
  • Added a regex in useMarkdown to escape uppercase-starting angle bracket patterns (e.g. <T>, <TSend, TRecv>) to HTML entities before MDX processing
  • Only affects TypeScript-style generics (uppercase start), not actual HTML tags (lowercase)

Test plan

  • Verified /x/worker/ renders correctly with README + API reference (155KB vs 13KB error page)
  • Verified /x/fetch/, /x/websocket/, /x/process/ still render correctly
  • No server errors in console

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 22, 2026

Open in StackBlitz

npm i https://pkg.pr.new/effection@1142

commit: c150da7

Copy link
Copy Markdown
Member

@cowboyd cowboyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. One thing though: Can you ask Claude not to market itself by adding itself to commits and PRs?

JSDoc comments containing generic type references like `Result<T>` were
being interpreted as JSX tags by MDX, causing the worker extension page
to fail with a parse error. Escape uppercase-starting angle bracket
patterns to HTML entities before MDX processing.
@taras taras force-pushed the fix/escape-generic-type-params-in-mdx branch from 9f37d80 to c150da7 Compare April 5, 2026 11:58
@taras taras merged commit 76d8571 into v4 Apr 5, 2026
17 checks passed
@taras taras deleted the fix/escape-generic-type-params-in-mdx branch April 5, 2026 12:01
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.

3 participants