Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions apps/dashboard/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ GITHUB_CLIENT_SECRET=
# How to get these:
# 1. Go to https://github.com/settings/apps → New GitHub App
# 2. Set "Callback URL" to http://localhost:3000/api/github/app/callback
# 3. Set "Setup URL" to http://localhost:3000/?show-org-setup=true
# 3. Set "Setup URL" to http://localhost:3000/setup
# 4. Check "Redirect on update"
# 5. Leave "Request user authorization (OAuth) during installation" UNCHECKED
# 6. Grant the permissions listed in the README
Expand All @@ -55,7 +55,8 @@ GITHUB_APP_ID=
# GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIE...\n-----END RSA PRIVATE KEY-----\n"
#
# Quick conversion from the downloaded .pem file:
# awk 'NF {printf "%s\\n", $0}' /path/to/key.pem
# macOS / Linux: awk 'NF {printf "%s\\n", $0}' /path/to/key.pem
# PowerShell: (Get-Content key.pem -Raw) -replace "`r`n","\n" -replace "`n","\n"
#
# GitHub downloads PKCS#1 keys ("BEGIN RSA PRIVATE KEY"); DiffKit auto-converts
# to PKCS#8 at runtime — no manual conversion needed.
Expand All @@ -70,7 +71,9 @@ GITHUB_APP_SLUG=
# Secret used to verify webhook payloads from GitHub (HMAC-SHA256).
# Set the same value in your GitHub App settings under "Webhook secret".
#
# Generate one with: openssl rand -hex 20
# Generate one with:
# macOS / Linux: openssl rand -hex 20
# PowerShell: -join ((1..20) | ForEach-Object { '{0:x2}' -f (Get-Random -Max 256) })
GITHUB_WEBHOOK_SECRET=

# -----------------------------------------------------------------------------
Expand All @@ -79,7 +82,9 @@ GITHUB_WEBHOOK_SECRET=
# Random secret used by Better Auth to encrypt session cookies.
# Must be at least 32 characters.
#
# Generate one with: openssl rand -base64 32
# Generate one with:
# macOS / Linux: openssl rand -base64 32
# PowerShell: [Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Max 256 }))
BETTER_AUTH_SECRET=

# Base URL where DiffKit is running. Used by Better Auth for redirects.
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OAuth App:
GitHub App:

- Callback URL: `http://localhost:3000/api/github/app/callback`
- Setup URL: `http://localhost:3000/?show-org-setup=true`
- Setup URL: `http://localhost:3000/setup`
- Enable **Redirect on update**
- Leave **Request user authorization (OAuth) during installation** unchecked
- Environment variables: `GITHUB_APP_CLIENT_ID`, `GITHUB_APP_CLIENT_SECRET`, `GITHUB_APP_ID`, `GITHUB_APP_PRIVATE_KEY`, `GITHUB_APP_SLUG`, `GITHUB_WEBHOOK_SECRET`
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"scripts": {
"predev": "node ../../scripts/link-worktree-dev-vars.mjs",
"dev": "vite dev --port 3000",
"dev": "NODE_OPTIONS='--max-old-space-size=8192' vite dev --port 3000",
"build": "vite build",
"preview": "vite preview",
"test": "vitest run",
Expand Down
69 changes: 69 additions & 0 deletions apps/dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,80 @@ export default {};`;
};
}

// Stub out client-only packages in the SSR environment to reduce the workerd
// V8 heap footprint. These libraries are only used for client-side rendering
// (animations, number transitions, diff viewers, devtools) and are never
// needed during server-side rendering. Without these stubs, workerd can hit
// its ~1.4 GB V8 heap limit and OOM on memory-constrained systems (e.g. WSL2).
function clientOnlySSRStubs(): import("vite").Plugin {
const CLIENT_ONLY_PACKAGES = [
"motion",
"@number-flow/react",
"@pierre/diffs",
"@tanstack/react-devtools",
"@tanstack/react-router-devtools",
];

const STUB_PREFIX = "\0client-stub:";

const MOTION_STUB = `
const noop = () => {};
const noopObj = { get: noop, set: noop, on: noop, stop: noop, destroy: noop };
const handler = { get: (_, prop) => typeof prop === "symbol" ? undefined : prop };
export const motion = new Proxy({}, handler);
export const AnimatePresence = ({ children }) => children;
export const useMotionValue = () => noopObj;
export const useTransform = () => noopObj;
export const animate = () => ({ stop: noop });
export default {};`;

const STUBS: Record<string, string> = {
motion: MOTION_STUB,
"@number-flow/react": `export default function NumberFlow({ value }) { return String(value ?? ""); }`,
"@pierre/diffs": `export const registerCustomTheme = () => {}; export default {};`,
"@pierre/diffs/react": `const noop = () => null; export default noop;`,
"@tanstack/react-devtools": `export function TanStackDevtools() { return null; }`,
"@tanstack/react-router-devtools": `export function TanStackRouterDevtoolsPanel() { return null; }`,
};

function isClientOnly(source: string) {
return CLIENT_ONLY_PACKAGES.some(
(pkg) => source === pkg || source.startsWith(`${pkg}/`),
);
}

function getStub(source: string) {
if (STUBS[source]) return STUBS[source];
for (const [pkg, stub] of Object.entries(STUBS)) {
if (source.startsWith(`${pkg}/`)) return stub;
}
return `export default {};`;
}

return {
name: "client-only-ssr-stubs",
enforce: "pre",
resolveId: {
handler(source) {
if (this.environment?.name === "ssr" && isClientOnly(source)) {
return `${STUB_PREFIX}${source}`;
}
},
},
load(id) {
if (id.startsWith(STUB_PREFIX)) {
return getStub(id.slice(STUB_PREFIX.length));
}
},
};
}

const config = defineConfig(({ command }) => ({
server: command === "serve" ? getTunnelServerConfig() : undefined,
plugins: [
devtools(),
shikiSSRStub(),
clientOnlySSRStubs(),
cloudflare({
viteEnvironment: { name: "ssr" },
...worktreePersistState,
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"lightningcss",
"sharp",
"workerd"
]
],
"patchedDependencies": {
"miniflare@4.20260409.0": "patches/miniflare@4.20260409.0.patch"
}
}
}
12 changes: 12 additions & 0 deletions patches/miniflare@4.20260409.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/dist/src/index.js b/dist/src/index.js
index 4f02a86f29bdb38533512e4744cfc384b29a3327..83b7ec764f3f0e0776cf955b5e0c15d1db859416 100644
--- a/dist/src/index.js
+++ b/dist/src/index.js
@@ -87406,6 +87406,7 @@ var Miniflare = class _Miniflare {
services: servicesArray,
sockets,
extensions,
+ v8Flags: ["--max-heap-size=4096"],
structuredLogging: this.#structuredWorkerdLogs
};
}
11 changes: 8 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading