Fixes xbrowsersync/app#190 #518
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.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
getNativeContainerIds()with position-based container detection fallbackclearNativeBookmarksFallback()method for recovery when container IDs are unavailableclearNativeBookmarks()to catchContainerNotFoundErrorand attempt fallback recoveryTesting
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).