mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a new "Hosted Components" app with its own app shell, routing, auth-aware UI, a handler route, and a welcome page showing the signed-in user. * **Chores** * Added dev tooling and configuration for the new app (build, lint, typecheck, Vite/TS, package manifest) and updated dev env API URL. * **Tests** * Excluded the new app from the test workspace. * **Bug Fixes** * Suppressed noisy console errors for a specific internal sentinel and clarified related error messaging. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Konstantin Wohlwend <n2d4xc@gmail.com>
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
import { createGlobal } from "./globals";
|
|
|
|
export const NO_SUSPENSE_BOUNDARY_ERROR_SENTINEL = "__stack-no-suspense-boundary-error__";
|
|
|
|
export function isNoSuspenseBoundaryError(value: unknown): boolean {
|
|
return (
|
|
typeof value === "object"
|
|
&& value !== null
|
|
&& (value as Record<string, unknown>).__noSuspenseBoundarySentinel === NO_SUSPENSE_BOUNDARY_ERROR_SENTINEL
|
|
);
|
|
}
|
|
|
|
export function ensureMonkeyPatch() {
|
|
createGlobal("__console-error-monkey-patch__", () => {
|
|
const originalConsoleError = console.error;
|
|
console.error = function (...args: unknown[]) {
|
|
// React's default error handlers will log all errors to the console, even those that we intentionally use to suppress SSR.
|
|
// Next.js among others override the default error handler and will not log SSR errors to the console.
|
|
// However, vanilla React and other frameworks like TanStack Start use the default error handler.
|
|
// Hence, we suppress the error here if it is a NoSuspenseBoundaryError.
|
|
// It's very cursed, but it's really our best option. Talk to @konsti if you want to know more.
|
|
if (args.length === 1 && isNoSuspenseBoundaryError(args[0])) {
|
|
return;
|
|
}
|
|
return originalConsoleError.apply(this, args);
|
|
};
|
|
return true;
|
|
});
|
|
}
|