Skip to content

Conversation

lanmower
Copy link

@lanmower lanmower commented Sep 7, 2025

Summary

  • Add WebSocket-based error monitoring for immediate feedback when setting app code
  • Add blueprint validation to prevent invalid entity creation
  • Enable immediate error responses when problematic app code is deployed
  • Prevent entities with missing/invalid blueprints from persisting in world state

Changes

  • Entities.js: Add blueprint validation check in add() method to prevent invalid entity creation
  • ErrorMonitor.js: Add minimal onErrorReport handler for WebSocket error reception
  • ServerNetwork.js: Remove duplicate handlers, simplify error management
  • packets.js: Added packet types for error communication
  • World.js: Register ErrorMonitor to capture initialization errors
  • Minor fixes: App.js and createServerWorld.js compatibility updates

Key Features

Entity Blueprint Validation: Prevents creation of entities with missing blueprints
WebSocket Error Monitoring: Real-time error feedback via WebSocket communication
Network Error Reporting: Failed entity creation attempts reported back to clients
System Stability: Maintains world integrity by rejecting incomplete entity data

Test plan

  • Test immediate error feedback when setting invalid app code
  • Verify WebSocket error communication works properly
  • Test blueprint validation prevents invalid entity creation
  • Confirm error reporting matches client/server responses exactly
  • Test MCP server integration with refined error monitoring

🤖 Generated with Claude Code

lanmower and others added 14 commits September 7, 2025 11:41
MINIMAL CHANGES:

1. Immediate Blueprint Error Feedback:
   - blueprintAdded/blueprintModified responses include errors when they occur
   - Catches GLTFLoader SyntaxErrors within 100ms of blueprint operations
   - Returns success/failure status with error details

2. WebSocket Error Commands:
   - Added getErrors/clearErrors packet types
   - Server handlers: onGetErrors(), onClearErrors()
   - Uses existing engine WebSocket patterns (no HTTP endpoints)

KISS Implementation - only essential code for immediate error response
and aggregate error collection via WebSocket like other engine systems.
- Add errorReport, getErrors, clearErrors packet types
- Register ErrorMonitor in World.js to capture initialization errors
- Add onErrorReport handler to receive error reports via WebSocket
- Remove duplicate error handlers to simplify ServerNetwork
- Enable immediate error responses when setting problematic app code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Forward model load errors directly to ErrorMonitor when console interception fails
- Forward script load errors directly to ErrorMonitor
- Bypass console.error override issues in server environment
- Ensure runtime errors reach MCP error monitoring system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fix TypeError: Cannot read properties of undefined (reading 'scene') that was
causing the Hyperfy client to freeze. The error occurred when accessing
blueprint properties on entities where the blueprint was undefined.

Changes:
- ClientBuilder.js: Added optional chaining (?.) for all blueprint property access
- App.js: Added null check before accessing blueprint.version in onEvent method

This prevents crashes during entity interaction, selection, duplication, and
event processing when blueprints are temporarily undefined during entity
initialization or when entities reference missing blueprints.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Reduced to absolute minimum changes needed for MCP error reporting:

Core Changes:
• ErrorMonitor.js - Essential error capture and WebSocket forwarding
• ServerNetwork.js - Minimal MCP integration methods only
• packets.js - Required error reporting packets

Removed:
• All debug logging ([ENTITY DEBUG], [SERVERNETWORK DEBUG])
• Unnecessary null safety checks not in original
• Duplicate/complex methods
• Performance optimizations
• Extra console.log statements

Result: Fork is now minimal with only essential MCP error reporting functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Silent fallback when console interception fails
- Cleaner server logs without repetitive warnings
- Maintains full error monitoring functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Disable console interception due to SES restrictions
- Keep only global error handlers (which work reliably)
- Much cleaner code without try/catch complexity
- Error monitoring still fully functional via global handlers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…crashes

Resolves script crashes not being captured by MCP error monitoring system.

Key changes:
- Added ErrorMonitor.captureError() calls to all script execution catch blocks
- Fixed broken error monitoring chain for server-side script crashes
- Added debug logging for error handler verification
- Affects script.exec(), fixedUpdate(), update(), lateUpdate() methods

Impact:
- Script crashes now properly reach MCP tools via ErrorMonitor
- Real-time error transmission enabled for create_model_blueprint responses
- Developers can immediately see script errors in MCP get_errors responses

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…et transmission

- Add onError callback to gltfLoader.parse() in ServerLoader.js
- Capture GLTF parsing errors (e.g., "Unterminated string in JSON") previously lost to stderr
- Integrate with ErrorMonitor system for immediate WebSocket transmission to MCP clients
- Fix both 'model' and 'emote' loading error handling
- Ensure blueprint creation failures send proper error packets via WebSocket
- Replace silent GLTF failures with detailed error reporting for debugging

Before: GLTF Parse Error → stderr only → MCP gets empty error arrays
After: GLTF Parse Error → ErrorMonitor → WebSocket → MCP gets detailed errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Removed unnecessary debug logging from error monitoring:
- Removed console.log statements from ServerNetwork.js error handling
- Removed console.error debug messages from ErrorMonitor.js
- Removed console.error debug statements from App.js error forwarding
- Removed console.error debug messages from ServerLoader.js GLTF errors
- Simplified error capture data structures
- Maintained core functionality: GLTF error capture, WebSocket transmission, MCP forwarding

Result: Clean minimal fork with essential error monitoring only.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add validation check in Entities.add() to prevent entities with missing blueprints
- Include network error reporting for failed entity creation attempts
- Maintains system stability by rejecting incomplete entity data
- Minimal targeted fix for blueprint validation issue

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant