Skip to content

Conversation

@Tahlor
Copy link

@Tahlor Tahlor commented Nov 21, 2025

Problem

The extension fails with "Missing container: other bookmarks" error when the browser's native bookmark container IDs don't match the expected hardcoded values ('1' for toolbar, '2' for other bookmarks). This can occur in certain browser configurations or when the bookmark structure has been modified. See #190

Solution

Added resilient container detection with two fallback mechanisms:

  1. Position-based fallback in getNativeContainerIds(): When hardcoded IDs don't match, the code now attempts to identify containers by their position in the bookmark tree (toolbar at index 0, other bookmarks at index 1). This works reliably for Chromium browsers which typically have exactly 2 root children.

  2. Recovery fallback in clearNativeBookmarks(): If container IDs still can't be found, the code now traverses the bookmark tree to find xBrowserSync containers by their titles ([xbs] Other, [xbs] Toolbar, [xbs] Menu) and clears them directly. This ensures bookmarks can be reset even when the native container structure is unexpected.

Changes

  • Enhanced getNativeContainerIds() with position-based container detection fallback
  • Added clearNativeBookmarksFallback() method for recovery when container IDs are unavailable
  • Updated clearNativeBookmarks() to catch ContainerNotFoundError and attempt fallback recovery
  • Added defensive checks to ensure position-based fallback only runs when root has exactly 2 children

Testing

  • Verified sync works when container IDs don't match expected values
  • Confirmed fallback recovery successfully clears bookmarks in error scenarios
  • Tested on Edge (Chromium-based) where container ID was '467' instead of expected '2'

Notes

This is a defensive programming approach that makes the extension resilient to browser implementation variations without attempting to modify the browser's native bookmark structure (which we don't control).

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