fullstack-debugger
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFullstack Debugger
全栈调试工具
Expert debugger for modern web stacks: Next.js 15, Cloudflare Workers, Supabase, and edge deployments. Systematic, evidence-based troubleshooting.
现代Web技术栈专属调试专家:支持Next.js 15、Cloudflare Workers、Supabase及边缘部署。基于证据的系统化排查方案。
Activation Triggers
触发条件
Activate on: "debug", "not working", "broken", "error", "500 error", "401", "403", "cache issue", "CORS error", "RLS policy", "auth not working", "blank page", "hydration error", "build failed", "worker not responding"
NOT for: Feature development → language skills | Architecture → | Performance optimization →
system-architectperformance-engineer触发关键词: "debug"、"not working"、"broken"、"error"、"500 error"、"401"、"403"、"cache issue"、"CORS error"、"RLS policy"、"auth not working"、"blank page"、"hydration error"、"build failed"、"worker not responding"
不适用场景: 功能开发 → 语言技能工具 | 架构设计 → | 性能优化 →
system-architectperformance-engineerDebug Philosophy
调试理念
1. REPRODUCE → Can you make it fail consistently?
2. ISOLATE → Which layer is broken?
3. EVIDENCE → What do logs/network/state show?
4. HYPOTHESIZE → What could cause this?
5. TEST → Validate one hypothesis at a time
6. FIX → Minimal change that resolves issue
7. VERIFY → Confirm fix doesn't break other things1. REPRODUCE → 能否稳定复现问题?
2. ISOLATE → 哪一层出现故障?
3. EVIDENCE → 日志/网络/状态显示了什么?
4. HYPOTHESIZE → 可能的原因是什么?
5. TEST → 逐一验证假设
6. FIX → 用最小的代码变更解决问题
7. VERIFY → 确认修复不会影响其他功能Architecture Layers
架构分层
┌─────────────────────────────────────────────────────────────┐
│ DEBUGGING LAYERS │
├─────────────────────────────────────────────────────────────┤
│ │
│ Layer 1: Browser/Client │
│ ├── Console errors, network tab, React DevTools │
│ ├── localStorage/sessionStorage state │
│ └── React Query cache state │
│ │
│ Layer 2: Next.js Application │
│ ├── Server components vs client components │
│ ├── Build output and static generation │
│ ├── API routes (if any) │
│ └── Hydration mismatches │
│ │
│ Layer 3: Cloudflare Workers │
│ ├── Worker logs (wrangler tail) │
│ ├── KV cache state │
│ ├── CORS headers │
│ └── Rate limiting │
│ │
│ Layer 4: Supabase │
│ ├── Auth state and JWT tokens │
│ ├── RLS policies (most common issue!) │
│ ├── Database queries and indexes │
│ └── Realtime subscriptions │
│ │
│ Layer 5: External APIs │
│ ├── Third-party service availability │
│ ├── API rate limits │
│ └── Response format changes │
│ │
└─────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────┐
│ DEBUGGING LAYERS │
├─────────────────────────────────────────────────────────────┤
│ │
│ Layer 1: Browser/Client │
│ ├── Console errors, network tab, React DevTools │
│ ├── localStorage/sessionStorage state │
│ └── React Query cache state │
│ │
│ Layer 2: Next.js Application │
│ ├── Server components vs client components │
│ ├── Build output and static generation │
│ ├── API routes (if any) │
│ └── Hydration mismatches │
│ │
│ Layer 3: Cloudflare Workers │
│ ├── Worker logs (wrangler tail) │
│ ├── KV cache state │
│ ├── CORS headers │
│ └── Rate limiting │
│ │
│ Layer 4: Supabase │
│ ├── Auth state and JWT tokens │
│ ├── RLS policies (most common issue!) │
│ ├── Database queries and indexes │
│ └── Realtime subscriptions │
│ │
│ Layer 5: External APIs │
│ ├── Third-party service availability │
│ ├── API rate limits │
│ └── Response format changes │
│ │
└─────────────────────────────────────────────────────────────┘Quick Diagnosis Commands
快速诊断命令
Check Everything At Once
一次性检查所有内容
bash
undefinedbash
undefinedRun from next-app/ directory
Run from next-app/ directory
echo "=== Build Check ===" && npm run build 2>&1 | tail -20
echo "=== TypeScript ===" && npx tsc --noEmit 2>&1 | head -20
echo "=== Lint ===" && npm run lint 2>&1 | head -20
echo "=== Git Status ===" && git status --short
undefinedecho "=== Build Check ===" && npm run build 2>&1 | tail -20
echo "=== TypeScript ===" && npx tsc --noEmit 2>&1 | head -20
echo "=== Lint ===" && npm run lint 2>&1 | head -20
echo "=== Git Status ===" && git status --short
undefinedSupabase RLS Diagnosis
Supabase RLS 诊断
bash
undefinedbash
undefinedCheck if RLS is blocking queries (most common issue!)
Check if RLS is blocking queries (most common issue!)
node -e "
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(
'YOUR_SUPABASE_URL',
'YOUR_ANON_KEY'
);
async function diagnose() {
// Test as anonymous user
const { data, error, count } = await supabase
.from('YOUR_TABLE')
.select('*', { count: 'exact' })
.limit(5);
console.log('Error:', error);
console.log('Count:', count);
console.log('Sample:', data);
}
diagnose();
"
undefinednode -e "
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(
'YOUR_SUPABASE_URL',
'YOUR_ANON_KEY'
);
async function diagnose() {
// Test as anonymous user
const { data, error, count } = await supabase
.from('YOUR_TABLE')
.select('*', { count: 'exact' })
.limit(5);
console.log('Error:', error);
console.log('Count:', count);
console.log('Sample:', data);
}
diagnose();
"
undefinedWorker Health Check
Worker 健康检查
bash
undefinedbash
undefinedCheck if workers are responding
Check if workers are responding
curl -s -o /dev/null -w "%{http_code}" https://YOUR-WORKER.workers.dev/health
curl -s -o /dev/null -w "%{http_code}" https://YOUR-WORKER.workers.dev/health
Check CORS headers
Check CORS headers
curl -s -D - -o /dev/null -H "Origin: https://yoursite.com"
https://YOUR-WORKER.workers.dev/api/endpoint | grep -iE "(access-control|x-)"
https://YOUR-WORKER.workers.dev/api/endpoint | grep -iE "(access-control|x-)"
curl -s -D - -o /dev/null -H "Origin: https://yoursite.com"
https://YOUR-WORKER.workers.dev/api/endpoint | grep -iE "(access-control|x-)"
https://YOUR-WORKER.workers.dev/api/endpoint | grep -iE "(access-control|x-)"
Stream worker logs
Stream worker logs
cd workers/your-worker && npx wrangler tail
undefinedcd workers/your-worker && npx wrangler tail
undefinedCache Inspection
缓存检查
bash
undefinedbash
undefinedCheck Cloudflare KV cache
Check Cloudflare KV cache
npx wrangler kv:key list --namespace-id=YOUR_NAMESPACE_ID | head -20
npx wrangler kv:key list --namespace-id=YOUR_NAMESPACE_ID | head -20
Get specific cached value
Get specific cached value
npx wrangler kv:key get --namespace-id=YOUR_NAMESPACE_ID "cache:key"
npx wrangler kv:key get --namespace-id=YOUR_NAMESPACE_ID "cache:key"
Clear a cached item
Clear a cached item
npx wrangler kv:key delete --namespace-id=YOUR_NAMESPACE_ID "cache:key"
undefinednpx wrangler kv:key delete --namespace-id=YOUR_NAMESPACE_ID "cache:key"
undefinedCommon Issues & Solutions
常见问题与解决方案
1. RLS Policy Blocking Data (Most Common!)
1. RLS 策略阻止数据访问(最常见!)
Symptoms:
- Query returns empty array but no error
- Works in Supabase dashboard but not in app
- Works for some users but not others
Diagnosis:
sql
-- In Supabase SQL Editor
-- Check what policies exist
SELECT schemaname, tablename, policyname, permissive, roles, cmd, qual
FROM pg_policies
WHERE tablename = 'your_table';
-- Test as anonymous user
SET ROLE anon;
SELECT * FROM your_table LIMIT 5;
RESET ROLE;
-- Test as authenticated user
SET ROLE authenticated;
SET request.jwt.claims = '{"sub": "user-uuid-here"}';
SELECT * FROM your_table LIMIT 5;
RESET ROLE;Common Fixes:
sql
-- Allow public read access
CREATE POLICY "Allow public read" ON your_table
FOR SELECT USING (true);
-- Allow authenticated users to read
CREATE POLICY "Allow authenticated read" ON your_table
FOR SELECT TO authenticated USING (true);
-- Allow users to read their own data
CREATE POLICY "Users read own data" ON your_table
FOR SELECT USING (auth.uid() = user_id);症状:
- 查询返回空数组但无错误
- 在Supabase控制台中正常,但在应用中异常
- 部分用户正常,部分用户异常
诊断:
sql
-- In Supabase SQL Editor
-- Check what policies exist
SELECT schemaname, tablename, policyname, permissive, roles, cmd, qual
FROM pg_policies
WHERE tablename = 'your_table';
-- Test as anonymous user
SET ROLE anon;
SELECT * FROM your_table LIMIT 5;
RESET ROLE;
-- Test as authenticated user
SET ROLE authenticated;
SET request.jwt.claims = '{"sub": "user-uuid-here"}';
SELECT * FROM your_table LIMIT 5;
RESET ROLE;常见修复方案:
sql
-- Allow public read access
CREATE POLICY "Allow public read" ON your_table
FOR SELECT USING (true);
-- Allow authenticated users to read
CREATE POLICY "Allow authenticated read" ON your_table
FOR SELECT TO authenticated USING (true);
-- Allow users to read their own data
CREATE POLICY "Users read own data" ON your_table
FOR SELECT USING (auth.uid() = user_id);2. CORS Errors
2. CORS 错误
Symptoms:
- "Access to fetch blocked by CORS policy"
- Works in Postman but not in browser
- Preflight request fails
Diagnosis:
bash
undefined症状:
- "Access to fetch blocked by CORS policy"
- 在Postman中正常,但在浏览器中异常
- 预检请求失败
诊断:
bash
undefinedCheck what CORS headers are returned
Check what CORS headers are returned
curl -s -D - -o /dev/null
-H "Origin: https://yoursite.com"
-H "Access-Control-Request-Method: POST"
-X OPTIONS
https://your-worker.workers.dev/api/endpoint
-H "Origin: https://yoursite.com"
-H "Access-Control-Request-Method: POST"
-X OPTIONS
https://your-worker.workers.dev/api/endpoint
**Fix in Cloudflare Worker:**
```typescript
// In your worker
const corsHeaders = {
'Access-Control-Allow-Origin': '*', // Or specific domain
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
};
// Handle preflight
if (request.method === 'OPTIONS') {
return new Response(null, { headers: corsHeaders });
}
// Add to all responses
return new Response(data, {
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});curl -s -D - -o /dev/null
-H "Origin: https://yoursite.com"
-H "Access-Control-Request-Method: POST"
-X OPTIONS
https://your-worker.workers.dev/api/endpoint
-H "Origin: https://yoursite.com"
-H "Access-Control-Request-Method: POST"
-X OPTIONS
https://your-worker.workers.dev/api/endpoint
**Cloudflare Worker 中的修复方案:**
```typescript
// In your worker
const corsHeaders = {
'Access-Control-Allow-Origin': '*', // Or specific domain
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
};
// Handle preflight
if (request.method === 'OPTIONS') {
return new Response(null, { headers: corsHeaders });
}
// Add to all responses
return new Response(data, {
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});3. Auth State Not Persisting
3. 认证状态无法持久化
Symptoms:
- User logged in but shows as logged out on refresh
- Auth works locally but not in production
- Session disappears randomly
Diagnosis:
javascript
// In browser console
console.log('Session:', await supabase.auth.getSession());
console.log('User:', await supabase.auth.getUser());
console.log('LocalStorage:', Object.keys(localStorage).filter(k => k.includes('supabase')));Common Fixes:
- Check Supabase URL matches (http vs https, trailing slash)
- Verify site URL in Supabase Auth settings
- Check for cookie blocking (Safari, incognito)
- Ensure AuthContext wraps all components needing auth
症状:
- 用户已登录,但刷新后显示未登录
- 本地环境正常,但生产环境异常
- 会话随机消失
诊断:
javascript
// In browser console
console.log('Session:', await supabase.auth.getSession());
console.log('User:', await supabase.auth.getUser());
console.log('LocalStorage:', Object.keys(localStorage).filter(k => k.includes('supabase')));常见修复方案:
- 检查Supabase URL是否匹配(http/https、末尾斜杠)
- 验证Supabase认证设置中的站点URL
- 检查是否有Cookie被阻止(Safari、隐身模式)
- 确保AuthContext包裹所有需要认证的组件
4. Hydration Mismatch
4. Hydration 不匹配
Symptoms:
- "Hydration failed because the initial UI does not match"
- Content flashes on page load
- Different content on server vs client
Diagnosis:
typescript
// Temporarily add to suspect component
useEffect(() => {
console.log('Client render:', document.body.innerHTML.slice(0, 500));
}, []);Common Fixes:
typescript
// Use client-only rendering for dynamic content
'use client';
import { useState, useEffect } from 'react';
function DynamicContent() {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) return null; // or skeleton
return <div>{/* dynamic content */}</div>;
}症状:
- "Hydration failed because the initial UI does not match"
- 页面加载时内容闪烁
- 服务端与客户端渲染内容不一致
诊断:
typescript
// Temporarily add to suspect component
useEffect(() => {
console.log('Client render:', document.body.innerHTML.slice(0, 500));
}, []);常见修复方案:
typescript
// Use client-only rendering for dynamic content
'use client';
import { useState, useEffect } from 'react';
function DynamicContent() {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) return null; // or skeleton
return <div>{/* dynamic content */}</div>;
}5. Worker Not Deploying
5. Worker 部署失败
Symptoms:
- Deploy command succeeds but changes not reflected
- Old code still running
- Intermittent old/new behavior
Diagnosis:
bash
undefined症状:
- 部署命令执行成功,但变更未生效
- 仍运行旧代码
- 新旧代码行为交替出现
诊断:
bash
undefinedCheck deployment status
Check deployment status
npx wrangler deployments list
npx wrangler deployments list
View current worker code
View current worker code
npx wrangler deployments view
npx wrangler deployments view
Check for multiple environments
Check for multiple environments
npx wrangler whoami
**Fixes:**
```bashnpx wrangler whoami
**修复方案:**
```bashForce redeploy
Force redeploy
npx wrangler deploy --force
npx wrangler deploy --force
Clear Cloudflare cache
Clear Cloudflare cache
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache"
-H "Authorization: Bearer YOUR_TOKEN"
-H "Content-Type: application/json"
--data '{"purge_everything":true}'
-H "Authorization: Bearer YOUR_TOKEN"
-H "Content-Type: application/json"
--data '{"purge_everything":true}'
undefinedcurl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache"
-H "Authorization: Bearer YOUR_TOKEN"
-H "Content-Type: application/json"
--data '{"purge_everything":true}'
-H "Authorization: Bearer YOUR_TOKEN"
-H "Content-Type: application/json"
--data '{"purge_everything":true}'
undefined6. TypeScript Cache Haunting
6. TypeScript 缓存问题
Symptoms:
- Errors reference deleted/changed code
- Types don't match current code
- "Cannot find module" for existing files
Fix:
bash
undefined症状:
- 错误引用已删除/修改的代码
- 类型与当前代码不匹配
- "Cannot find module" 错误但文件存在
修复方案:
bash
undefinedNuclear option - clear all caches
Nuclear option - clear all caches
rm -rf .next node_modules/.cache tsconfig.tsbuildinfo
npm run build
rm -rf .next node_modules/.cache tsconfig.tsbuildinfo
npm run build
Or just TypeScript cache
Or just TypeScript cache
rm -rf node_modules/.cache/typescript
npx tsc --build --clean
undefinedrm -rf node_modules/.cache/typescript
npx tsc --build --clean
undefined7. Static Export Issues
7. 静态导出问题
Symptoms:
- "Error: Page X couldn't be rendered statically"
- Dynamic routes fail in static export
- API routes don't work after deploy
Diagnosis:
bash
undefined症状:
- "Error: Page X couldn't be rendered statically"
- 动态路由在静态导出中失败
- 部署后API路由无法工作
诊断:
bash
undefinedCheck next.config for output mode
Check next.config for output mode
grep -A5 "output:" next.config.ts
grep -A5 "output:" next.config.ts
Find dynamic components
Find dynamic components
grep -r "useSearchParams|usePathname|cookies()|headers()" src/
**Fixes:**
```typescript
// For components using dynamic APIs
export const dynamic = 'force-dynamic';
// or wrap in Suspense with fallback
// For generateStaticParams
export async function generateStaticParams() {
return [{ slug: 'page1' }, { slug: 'page2' }];
}grep -r "useSearchParams|usePathname|cookies()|headers()" src/
**修复方案:**
```typescript
// For components using dynamic APIs
export const dynamic = 'force-dynamic';
// or wrap in Suspense with fallback
// For generateStaticParams
export async function generateStaticParams() {
return [{ slug: 'page1' }, { slug: 'page2' }];
}8. Rate Limiting Issues
8. 速率限制问题
Symptoms:
- 429 errors after several requests
- Works initially then stops
- Different behavior per IP
Diagnosis:
bash
undefined症状:
- 多次请求后出现429错误
- 初始正常后停止工作
- 不同IP行为不同
诊断:
bash
undefinedCheck rate limit headers
Check rate limit headers
curl -i https://your-worker.workers.dev/api/endpoint 2>&1 | grep -i ratelimit
curl -i https://your-worker.workers.dev/api/endpoint 2>&1 | grep -i ratelimit
Check KV for rate limit keys
Check KV for rate limit keys
npx wrangler kv:key list --namespace-id=RATE_LIMIT_KV_ID | grep rate
**Fixes:**
```bashnpx wrangler kv:key list --namespace-id=RATE_LIMIT_KV_ID | grep rate
**修复方案:**
```bashClear rate limit for an IP
Clear rate limit for an IP
npx wrangler kv:key delete --namespace-id=RATE_LIMIT_KV_ID "rate:192.168.1.1"
npx wrangler kv:key delete --namespace-id=RATE_LIMIT_KV_ID "rate:192.168.1.1"
Adjust limits in wrangler.toml
Adjust limits in wrangler.toml
RATE_LIMIT_REQUESTS = "100"
RATE_LIMIT_WINDOW = "3600"
undefinedRATE_LIMIT_REQUESTS = "100"
RATE_LIMIT_WINDOW = "3600"
undefined9. Meeting/Location Data Issues
9. 会议/位置数据问题
Symptoms:
- No meetings found in certain areas
- Stale meeting data
- Cache showing wrong data
Diagnosis:
bash
undefined症状:
- 特定区域无法找到会议
- 会议数据过时
- 缓存显示错误数据
诊断:
bash
undefinedCheck cache status for a location
Check cache status for a location
curl -s -D - -o /dev/null
-H "Origin: https://yoursite.com"
"https://your-proxy.workers.dev/api/all?lat=45.52&lng=-122.68&radius=25"
| grep -iE "(x-cache|x-geohash|x-source)"
-H "Origin: https://yoursite.com"
"https://your-proxy.workers.dev/api/all?lat=45.52&lng=-122.68&radius=25"
| grep -iE "(x-cache|x-geohash|x-source)"
curl -s -D - -o /dev/null
-H "Origin: https://yoursite.com"
"https://your-proxy.workers.dev/api/all?lat=45.52&lng=-122.68&radius=25"
| grep -iE "(x-cache|x-geohash|x-source)"
-H "Origin: https://yoursite.com"
"https://your-proxy.workers.dev/api/all?lat=45.52&lng=-122.68&radius=25"
| grep -iE "(x-cache|x-geohash|x-source)"
Force cache refresh
Force cache refresh
Check Supabase for meeting count
Check Supabase for meeting count
node -e "
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient('URL', 'KEY');
supabase.from('meetings').select('*', { count: 'exact', head: true })
.then(({count}) => console.log('Total meetings:', count));
"
undefinednode -e "
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient('URL', 'KEY');
supabase.from('meetings').select('*', { count: 'exact', head: true })
.then(({count}) => console.log('Total meetings:', count));
"
undefined10. Build Fails on Cloudflare Pages
10. Cloudflare Pages 构建失败
Symptoms:
- Works locally but fails on deploy
- "Module not found" errors
- Memory exceeded
Diagnosis:
bash
undefined症状:
- 本地正常但部署失败
- "Module not found" 错误
- 内存不足
诊断:
bash
undefinedCheck build output locally
Check build output locally
NODE_ENV=production npm run build 2>&1 | tee build.log
NODE_ENV=production npm run build 2>&1 | tee build.log
Check for conditional imports
Check for conditional imports
grep -r "require(" src/ --include=".ts" --include=".tsx"
grep -r "require(" src/ --include=".ts" --include=".tsx"
Check bundle size
Check bundle size
npx next-bundle-analyzer
**Fixes:**
```javascript
// next.config.ts - increase memory
module.exports = {
experimental: {
memoryBasedWorkersCount: true,
},
// Reduce bundle size
webpack: (config) => {
config.externals = [...(config.externals || []), 'sharp'];
return config;
}
};npx next-bundle-analyzer
**修复方案:**
```javascript
// next.config.ts - increase memory
module.exports = {
experimental: {
memoryBasedWorkersCount: true,
},
// Reduce bundle size
webpack: (config) => {
config.externals = [...(config.externals || []), 'sharp'];
return config;
}
};Debug Scripts
调试脚本
scripts/diagnose.sh
scripts/diagnose.shscripts/diagnose.sh
scripts/diagnose.shbash
#!/bin/bashbash
#!/bin/bashRun all diagnostics
Run all diagnostics
echo "=== Environment ==="
node -v && npm -v
echo "=== Dependencies ==="
npm ls --depth=0 2>&1 | grep -E "(UNMET|missing)"
echo "=== TypeScript ==="
npx tsc --noEmit 2>&1 | head -30
echo "=== Build ==="
npm run build 2>&1 | tail -30
echo "=== Workers ==="
for worker in workers/*/; do
echo "Worker: $worker"
(cd "$worker" && npx wrangler whoami 2>/dev/null)
done
echo "=== Supabase ==="
npx supabase status 2>/dev/null || echo "Supabase CLI not configured"
undefinedecho "=== Environment ==="
node -v && npm -v
echo "=== Dependencies ==="
npm ls --depth=0 2>&1 | grep -E "(UNMET|missing)"
echo "=== TypeScript ==="
npx tsc --noEmit 2>&1 | head -30
echo "=== Build ==="
npm run build 2>&1 | tail -30
echo "=== Workers ==="
for worker in workers/*/; do
echo "Worker: $worker"
(cd "$worker" && npx wrangler whoami 2>/dev/null)
done
echo "=== Supabase ==="
npx supabase status 2>/dev/null || echo "Supabase CLI not configured"
undefinedscripts/check-rls.js
scripts/check-rls.jsscripts/check-rls.js
scripts/check-rls.jsjavascript
// Check RLS policies are working correctly
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
);
async function checkTable(table) {
console.log(`\n=== Checking ${table} ===`);
const { data, error, count } = await supabase
.from(table)
.select('*', { count: 'exact' })
.limit(1);
if (error) {
console.log(`ERROR: ${error.message}`);
} else {
console.log(`OK: ${count} rows accessible`);
}
}
// Check critical tables
['profiles', 'meetings', 'forum_posts', 'journal_entries'].forEach(checkTable);javascript
// Check RLS policies are working correctly
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
);
async function checkTable(table) {
console.log(`\n=== Checking ${table} ===`);
const { data, error, count } = await supabase
.from(table)
.select('*', { count: 'exact' })
.limit(1);
if (error) {
console.log(`ERROR: ${error.message}`);
} else {
console.log(`OK: ${count} rows accessible`);
}
}
// Check critical tables
['profiles', 'meetings', 'forum_posts', 'journal_entries'].forEach(checkTable);Validation Checklist
验证清单
[ ] Can reproduce the issue consistently
[ ] Identified which layer is failing (client/Next/Worker/Supabase/API)
[ ] Checked browser console for errors
[ ] Checked network tab for failed requests
[ ] Checked worker logs (wrangler tail)
[ ] Verified RLS policies allow access
[ ] Tested with fresh browser/incognito
[ ] Cleared all caches (browser, React Query, KV, TS)
[ ] Checked environment variables match production
[ ] Verified CORS headers are correct
[ ] Tested on production URL (not just localhost)
[ ] Created minimal reproduction case[ ] Can reproduce the issue consistently
[ ] Identified which layer is failing (client/Next/Worker/Supabase/API)
[ ] Checked browser console for errors
[ ] Checked network tab for failed requests
[ ] Checked worker logs (wrangler tail)
[ ] Verified RLS policies allow access
[ ] Tested with fresh browser/incognito
[ ] Cleared all caches (browser, React Query, KV, TS)
[ ] Checked environment variables match production
[ ] Verified CORS headers are correct
[ ] Tested on production URL (not just localhost)
[ ] Created minimal reproduction caseOutput
输出要求
When debugging, always provide:
- Root cause - What exactly was wrong
- Evidence - Logs, errors, or queries that proved it
- Fix - Minimal code change to resolve
- Verification - How to confirm it's fixed
- Prevention - How to avoid this in future
调试时请始终提供以下内容:
- 根本原因 - 具体问题所在
- 证据 - 证明问题的日志、错误或查询结果
- 修复方案 - 解决问题的最小代码变更
- 验证方式 - 如何确认问题已修复
- 预防措施 - 未来如何避免此类问题
Tools Available
可用工具
- ,
Read,Write- File operationsEdit - - Run commands, curl, wrangler
Bash - ,
Grep- Search codebaseGlob - - Test endpoints
WebFetch - - Direct Supabase operations
mcp__supabase__* - - Browser automation for UI testing
mcp__playwright__*
- ,
Read,Write- 文件操作Edit - - 执行命令、curl、wrangler
Bash - ,
Grep- 搜索代码库Glob - - 测试端点
WebFetch - - 直接操作Supabase
mcp__supabase__* - - 浏览器自动化UI测试
mcp__playwright__*