Re-enable Discord widget with enhanced error logging for GraphQL debugging
All checks were successful
Build / build (push) Successful in 1m31s
All checks were successful
Build / build (push) Successful in 1m31s
Previously disabled due to GraphQL errors. Now re-enabled with comprehensive error logging to diagnose the specific issue. Changes to discordWidget.ts: - Wrapped initialization in try-catch with detailed error logging - Added step-by-step console logs through initialization process - Added error event listener on the widget - Added window.onerror handler to catch widgetbot/GraphQL errors Changes to main.ts: - Uncommented Discord widget initialization - Added detailed error logging in catch block - Log error type, message, stack, and GraphQL response if available Next steps: - Load the application in browser - Check console for detailed error messages - Identify specific GraphQL query/mutation causing issues - Server ID: 1112846185913401475 - Channel ID: 1437561367908581406 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9b22b06d08
commit
8275c53fe4
11
src/main.ts
11
src/main.ts
@ -623,9 +623,7 @@ router.on('/', async () => {
|
|||||||
const demo = new Demo(main);
|
const demo = new Demo(main);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discord widget initialization - DISABLED FOR NOW
|
// Discord widget initialization with enhanced error logging
|
||||||
// Uncomment to enable Discord chat widget
|
|
||||||
/*
|
|
||||||
if (!(window as any).__discordWidget) {
|
if (!(window as any).__discordWidget) {
|
||||||
debugLog('[Router] Initializing Discord widget');
|
debugLog('[Router] Initializing Discord widget');
|
||||||
const discord = new DiscordWidget();
|
const discord = new DiscordWidget();
|
||||||
@ -642,9 +640,14 @@ router.on('/', async () => {
|
|||||||
(window as any).__discordWidget = discord;
|
(window as any).__discordWidget = discord;
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('[Router] Failed to initialize Discord widget:', error);
|
console.error('[Router] Failed to initialize Discord widget:', error);
|
||||||
|
console.error('[Router] Error type:', error?.constructor?.name);
|
||||||
|
console.error('[Router] Error message:', error?.message);
|
||||||
|
console.error('[Router] Error stack:', error?.stack);
|
||||||
|
if (error?.response) {
|
||||||
|
console.error('[Router] GraphQL response error:', error.response);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog('[Router] Home route handler complete');
|
debugLog('[Router] Home route handler complete');
|
||||||
|
|||||||
@ -24,15 +24,19 @@ export class DiscordWidget {
|
|||||||
* @param options - Widget configuration
|
* @param options - Widget configuration
|
||||||
*/
|
*/
|
||||||
async initialize(options: DiscordWidgetOptions): Promise<void> {
|
async initialize(options: DiscordWidgetOptions): Promise<void> {
|
||||||
|
try {
|
||||||
// Load the Crate script if not already loaded
|
// Load the Crate script if not already loaded
|
||||||
if (!this.scriptLoaded) {
|
if (!this.scriptLoaded) {
|
||||||
console.log('[DiscordWidget] Loading Crate script...');
|
console.log('[DiscordWidget] Loading Crate script...');
|
||||||
await this.loadCrateScript();
|
await this.loadCrateScript();
|
||||||
this.scriptLoaded = true;
|
this.scriptLoaded = true;
|
||||||
|
console.log('[DiscordWidget] Crate script loaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for Crate to be available on window
|
// Wait for Crate to be available on window
|
||||||
|
console.log('[DiscordWidget] Waiting for Crate constructor...');
|
||||||
await this.waitForCrate();
|
await this.waitForCrate();
|
||||||
|
console.log('[DiscordWidget] Crate constructor available');
|
||||||
|
|
||||||
// Initialize the Crate widget
|
// Initialize the Crate widget
|
||||||
const defaultOptions: DiscordWidgetOptions = {
|
const defaultOptions: DiscordWidgetOptions = {
|
||||||
@ -49,8 +53,18 @@ export class DiscordWidget {
|
|||||||
// @ts-ignore - Crate is loaded from CDN
|
// @ts-ignore - Crate is loaded from CDN
|
||||||
this.crate = new window.Crate(defaultOptions);
|
this.crate = new window.Crate(defaultOptions);
|
||||||
|
|
||||||
|
console.log('[DiscordWidget] Crate instance created, setting up event listeners...');
|
||||||
this.setupEventListeners();
|
this.setupEventListeners();
|
||||||
console.log('[DiscordWidget] Successfully initialized');
|
console.log('[DiscordWidget] Successfully initialized');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[DiscordWidget] Initialization failed:', error);
|
||||||
|
console.error('[DiscordWidget] Error details:', {
|
||||||
|
name: error?.constructor?.name,
|
||||||
|
message: error?.message,
|
||||||
|
stack: error?.stack
|
||||||
|
});
|
||||||
|
throw error; // Re-throw to be caught by caller
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,6 +131,30 @@ export class DiscordWidget {
|
|||||||
this.isVisible = visible;
|
this.isVisible = visible;
|
||||||
console.log('[DiscordWidget] Chat visibility:', visible);
|
console.log('[DiscordWidget] Chat visibility:', visible);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listen for any errors from the widget
|
||||||
|
this.crate.on('error', (error: any) => {
|
||||||
|
console.error('[DiscordWidget] Widget error event:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Monitor window errors that might be related to Discord widget
|
||||||
|
const originalErrorHandler = window.onerror;
|
||||||
|
window.onerror = (message, source, lineno, colno, error) => {
|
||||||
|
if (source?.includes('widgetbot') || message?.toString().includes('GraphQL')) {
|
||||||
|
console.error('[DiscordWidget] Window error (possibly related):', {
|
||||||
|
message,
|
||||||
|
source,
|
||||||
|
lineno,
|
||||||
|
colno,
|
||||||
|
error
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Call original handler if it existed
|
||||||
|
if (originalErrorHandler) {
|
||||||
|
return originalErrorHandler(message, source, lineno, colno, error);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user