Troubleshooting

CBWIRE integrates complex technologies like Livewire's DOM diffing, Alpine.js reactivity, and server-side rendering. This guide addresses the most common issues you'll encounter and provides practical solutions with detailed examples.

CBWIRE Component Issues

Lazy-Loaded Components with Placeholders Don't Render

Problem: You get a "Snapshot missing on Livewire component" error when using lazy loading with placeholders.

Root Cause: Mismatch between placeholder and template outer elements confuses Livewire's DOM diffing engine.

Error: Snapshot missing on Livewire component with id...

Solution: Match outer elements exactly between placeholder and template.

// wires/Widget.bx
class extends="cbwire.models.Component" {
    function placeholder() {
        return "<div>put spinner here...</div>"; // ✅ Matches template
    }
}
<!-- wires/widget.bxm -->
<bx:output>
<div> <!-- ✅ Matches placeholder's <div> -->
    <h1>My Widget</h1>
</div>
</bx:output>

Conditional Rendering Issues

Problem: Livewire fails to detect conditional sections appearing/disappearing, causing rendering glitches.

Root Cause: Complex nested conditionals can confuse Livewire's DOM diffing algorithm.

Solution: Add wire:key to conditional elements (recommended approach).

Alternative Solution: If wire:key doesn't solve the issue, add conditional block markers.

Block Marker Syntax:

Server Configuration Issues

400 Bad Request on CBWIRE Updates

Problem: The /cbwire/update endpoint returns "400 Bad Request" errors, preventing CBWIRE components from updating.

Root Cause: Server software or connectors stripping out the X-Livewire header that CBWIRE requires for request handling.

Error: HTTP 400 status code when CBWIRE attempts to process component updates.

Solution: Configure your server software to allow empty headers or preserve the X-Livewire header.

BonCode AJP Connector (IIS + Lucee)

If you're running Lucee behind IIS using the BonCode AJP Connector, you need to allow empty headers:

File: /BIN/BonCodeAJP13.settings

After making this change, restart your web server for the setting to take effect.

Other Server Software

The X-Livewire header is essential for CBWIRE to function properly. If you're experiencing 400 errors with other server configurations:

  1. Check server logs - Look for messages about rejected or stripped headers

  2. Review proxy settings - Ensure reverse proxies (nginx, Apache) pass through the X-Livewire header

  3. Check security modules - WAF or security modules might be filtering custom headers

  4. Test header presence - Use browser developer tools to verify the X-Livewire header is being sent

Example nginx configuration to preserve headers:

Example Apache configuration to preserve headers:

Alpine.js Integration Issues

Quote Syntax Errors in x-data

Problem: JavaScript errors when using double quotes inside x-data attributes.

Root Cause: HTML attribute already uses double quotes, creating syntax conflicts.

Error: JavaScript syntax error in browser console.

Solution: Use single quotes inside x-data blocks.

Component Removal with Alpine x-if

Problem: "Unable to find component" errors when using x-if with CBWIRE components.

Root Cause: Alpine's x-if completely removes/recreates DOM elements, breaking Livewire's component tracking.

Error: Unable to find component K8SDFLSDF902KSDFLASKJFASDFLJ.

Solution: Replace x-if with x-show to preserve DOM elements.

Key Differences: x-if vs x-show

Directive
Behavior
Use with CBWIRE

x-if

Removes/recreates DOM elements

❌ Breaks component tracking

x-show

Toggles CSS display property

✅ Preserves component tracking

Quick Reference

Essential Rules

  1. Placeholder-Template Matching: Outer elements must be identical

  2. Conditional Blocks: Wrap complex conditionals with <!--[if BLOCK]><![endif]--> markers

  3. Alpine Quotes: Always use single quotes inside x-data attributes

  4. Component Visibility: Use x-show instead of x-if with CBWIRE components

Common Error Messages

Error
Likely Cause
Solution

"Snapshot missing"

Placeholder/template mismatch

Match outer elements exactly

"Unable to find component"

Alpine x-if removing components

Use x-show instead

JavaScript syntax error

Double quotes in x-data

Use single quotes

400 Bad Request

X-Livewire header stripped by server

Configure server to allow empty headers

When in doubt, add wire:key to dynamic elements and wrap conditionals with block markers. These techniques help Livewire's DOM diffing engine track changes accurately.

Last updated

Was this helpful?