duydl / logseq-calibre-annotation

Other
20 stars 2 forks source link

Failed to load book manifest after clicking the "Open" button #1

Closed Plexprofile closed 8 months ago

Plexprofile commented 8 months ago

Bug Feedback: Failed to load book manifest after clicking the "Open" button

Description:

I encountered a bug while attempting to toggle book viewer, with a message saying Could not open Book id #2. The book manifest failed to load, click "Show details" for more information. The content server was already turned on and accessible through a web browser, and the calibre-metadata plugin is already properly set up and running.

Steps to Reproduce:

  1. Add a calibre book using the calibre-metadata plugin (nothing went wrong)
  2. Click the "Open" button renderer In the newly created calibre book page

Actual Result:

After clicking the "Open" button, an error message poped up saying "Could not open Book id #2. The book manifest failed to load, click "Show details" for more information."

As I clicked "Show details", I get this additional message: "Failed to communicate with "//book-manifest/2/EPUB?library_id=library&1696698123869", network error. Is the server running and accessible?"

When I clicked "book details", the error message said:

"Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'http:/#book_id=2&close_action=book_list&library_id=library&panel=book_details' cannot be created in a document with origin 'http://localhost:8080' and URL 'http://localhost:8080//#book_id=2&fmt=epub&library_id=library&mode=read_book'.
Error at http://localhost:8080//:11642:32
Traceback (most recent call last):
    at HTMLAnchorElement.ρσ_anonfunc (http://localhost:8080//:8626:54)
    at ρσ_anonfunc (http://localhost:8080//:50629:25)
    at show_panel (http://localhost:8080//:12174:35)
    at ρσ_interpolate_kwargs (http://localhost:8080//:3161:18)
    at push_state (http://localhost:8080//:11642:32)
Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'http:/#book_id=2&close_action=book_list&library_id=library&panel=book_details' cannot be created in a document with origin 'http://localhost:8080' and URL 'http://localhost:8080//#book_id=2&fmt=epub&library_id=library&mode=read_book'."

Additional Information:

calibre version 6.25.0 (portable) logseq version 0.9.18

Screenshots:

image image

duydl commented 8 months ago

But you could check the macro renderer for the open button i.e {{renderer calibreViewer, special, http://localhost:8080/#book_id=155&fmt=epub&library_id=Calibre&mode=read_book }} There is the link that opens the viewer. Paste it into the browser to see if the bug remains. If it is this is certainly a bug from calibre side.

Also, you could read your book in the browser, and highlight as you go. The annotation syncing should still work as expected.

Btw could you open other books or every book results in this error?

Plexprofile commented 8 months ago

The bug remains when I paste the link generated by the macro renderer into the browser, in my case, it is http://localhost:8080//#book_id=2&fmt=epub&library_id=library&mode=read_book, still the same error message

This link seems a little different from the one provided by the browser when I visit http://localhost:8080 and click "library", then the cover of the book, then the "read" button, which is http://localhost:8080/#book_id=2&fmt=EPUB&library_id=library&mode=read_book

If you compare these two links http://localhost:8080//#book_id=2&fmt=epub&library_id=library&mode=read_book (with bug) http://localhost:8080/#book_id=2&fmt=EPUB&library_id=library&mode=read_book (from the browser, without bug) You'll notice the browser generated link has the "E" in Capitalized form and it has a single instead of a double forward slash character, so I wonder if it is the difference in syntax that is causing the problem?

Plexprofile commented 8 months ago

Problem solved. I think the fault lies with use of the double forward slashes in the macro renderer because in every case when I replace them with a single forward the bug magically disappears.

duydl commented 8 months ago

Strange. Usually duplicate slashes would not result in bugs.
Well anyway, you could set the host link without the slash / in calibre metadata setting so next time you no longer need to remove it. I will add some fail-safe to ensure calibre-metadata generates links without duplicate slash later.

image