Skip to content

Fix: Doc feedback hashing crashes on HTTP origins - #1189

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/doc-feedback-http-hash
Open

Fix: Doc feedback hashing crashes on HTTP origins#1189
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/doc-feedback-http-hash

Conversation

@sentry

@sentry sentry Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: Cannot read properties of undefined (reading 'digest') that occurred when users accessed TanStack documentation over plain HTTP (non-secure origins).

Problem: The sha256Hex utility, located in src/utils/hash.ts, is used to generate content hashes for document feedback blocks. This utility directly calls crypto.subtle.digest, which is part of the Web Crypto API. However, crypto.subtle is undefined in non-secure browser contexts (i.e., when accessing pages via HTTP), leading to an unhandled TypeError and a page crash.

Solution:

  1. Introduced a fallback hash function: A simple, deterministic FNV-1a 32-bit hash (fnv1aHex) was added to src/utils/hash.ts. This hash is suitable for content identification where cryptographic security is not required, such as for doc feedback block IDs.
  2. Conditional hashing in sha256Hex: The sha256Hex function was modified to check for the availability of crypto?.subtle. If crypto.subtle is unavailable and the code is running in a browser environment (typeof window !== 'undefined'), it now falls back to using fnv1aHex.

This ensures that:

  • Pages accessed over HTTP no longer crash due to the missing crypto.subtle API.
  • Doc feedback block identification continues to function on HTTP origins using the fallback hash.
  • On HTTPS origins and in server environments (where crypto.subtle is always available and often required for database constraints), the cryptographically secure SHA-256 hash is still used, maintaining existing functionality and data integrity.

Fixes TANSTACK-COM-408

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 1b3e3ca Commit Preview URL

Branch Preview URL
Aug 29 2026, 11:05 AM

@tannerlinsley tannerlinsley added the source-audit Tracked by the automated source audit label Aug 29, 2026
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

source-audit Tracked by the automated source audit

项目

None yet

Development

Successfully merging this pull request may close these issues.

1 participant