Files
cremote/FIX_SUMMARY.md
Josh at WLTechBlog 051b912122 fix crash
2025-12-12 07:57:09 -07:00

1.4 KiB

Fix Summary: Rod Library Nil Map Panic

Problem

The cremote daemon crashed with panic: assignment to entry in nil map when calling WaitLoad() on a page object.

Root Cause

This is a known issue in go-rod v0.116.2 (https://github.com/go-rod/rod/issues/331).

When pages are retrieved using browser.Pages(), they are not fully initialized - internal maps are nil. When methods like WaitLoad() try to use these pages, they panic.

Solution

Modified daemon/daemon.go to properly initialize pages retrieved from browser.Pages():

Changes in findPageByID() (lines 2363-2400):

  • Added defer/recover to catch initialization panics
  • Call p.Info() to initialize internal page state
  • Return error if initialization fails
  • Added detailed comments explaining the issue

Changes in getTab() (lines 2428-2448):

  • Set up console logging for pages found via findPageByID
  • Added debug logging when caching existing tabs
  • Added comments explaining when this code path is used

Files Modified

  • daemon/daemon.go - Added page initialization and error handling
  • error.md - Documented the issue and fix

Testing

Code compiles successfully Proper error handling added Panic recovery in place

Next Steps

  1. Test with a scenario where daemon is restarted while browser is running
  2. Verify that pages are properly initialized before use
  3. Monitor for any similar panics in production