haroldtreen / epub-press-clients

📦 Clients for building books with EpubPress.
https://epub.press
GNU General Public License v3.0
592 stars 75 forks source link

Failed - Unexpected token < in JSON at position 0 #20

Open sTywin opened 7 years ago

sTywin commented 7 years ago

macOS: Sierra 10.12.5 Chrome: 58.0.3029.110 (64-bit)

Steps to reproduce: 1/ Open new Chrome window 2/ Navigate to https://seat14c.com/future_ideas 3/ Open each of the entries in the “Passenger Manifest” on the left-hand-side in a new tab, from top to bottom, including “The Origin Story” (but not including “Claim Your Seat”) 4/ Close the root tab, so that “The Origin Story” has focus 5/ Click the Epub.Press icon 6/ Enter the title “Seat 14C” 7/ Click “Select All” 8/ Click “Download”

Expected outcome:

Actual outcome:

Workaround:

haroldtreen commented 7 years ago

Thanks so much for this bug report @sTywin !

I'm debugging it now and will have an explanation shortly.

haroldtreen commented 7 years ago

I took a deeper look at the seat14c.com/future_ideas pages and they are unfortunately very large.

image

Each page is ~4Mb. EpubPress has a limit of 10Mb for any content sent.

Why the error?

nginx was being used to enforce that limit - it responds with html, but the extension expects json responses. So when it goes to parse the response it has a bad time.

Results

I've made it so that requests > 10 Mb and < 30 mb will get a friendlier error. Will need an extension update to catch the error for all cases.

I'm going to mark this as closed. Getting all those pages to work with EpubPress would require boosting the limit to

23 * 4Mb = 92 Mb

Allowing books that are ~100Mb large would degrade service for everyone and make the service more expensive to run.

Not the conclusion I had hoped for - sorry :(.

A separate issue exists for the JSON parsing bug, so I'll add these details and continue to track progress there.

Thanks again for the detailed bug report!

sTywin commented 7 years ago

Makes sense, thanks for the update. A friendlier error will help.

bkrlik commented 7 years ago

Today I received the same error on all the pages I tried to download, both on Chrome and Firefox.

bkrlik commented 7 years ago

Now it works.

haroldtreen commented 7 years ago

Thanks for the update @bkrlik!

Was off the grid the last few days and something went down 😬

bkrlik commented 7 years ago

Again it's no working :(

haroldtreen commented 7 years ago

Currently experiencing some server issues. Hope to have things back up soon.

Sorry for the inconvenience.

haroldtreen commented 7 years ago

Things are working again. Thanks again for alerting me @bkrlik !

jeffrechten commented 7 years ago

How do we get an updated client to fix this? I'm still running into the same issue.

haroldtreen commented 7 years ago

@jeffrechten If you're seeing the error it's because too much data is being sent. The fix would be to log a nice error that says:

Try sending less data...

Could be done in epub-press-js#normalizeErrors. I can do that this weekend, just hasn't been on the top of my priorities.

jeffrechten commented 7 years ago

@haroldtreen Would this be expected for one page of data? ~1200 lines, 110k characters.

haroldtreen commented 7 years ago

@jeffrechten One page doesn't seem like it should be an issue... but it could be? The amount of text on the page isn't what matters as much as the size of the html in the page. Sometimes pages download content in the background, store it in the page but hidden.

Do you have more information?

jeffrechten commented 7 years ago

@haroldtreen It's a yammer page I am logged into.

After I select the page for the book and click download, there isn't a books request. Also, the total size is not terribly large: I forced a refresh to capture any cached data. image

There are no errors in the console.

haroldtreen commented 7 years ago

@jeffrechten I think you're looking at an inspector for the yammer webpage.

To see what EpubPress is doing you'll need to:

That's where the request should be coming from.

jeffrechten commented 7 years ago

@haroldtreen Okay, I see. Sorry. Here's what I got:

image

haroldtreen commented 7 years ago

@jeffrechten Hmmm... so it's not responding with anything? That seems a bit strange...

What's in the Headers tab? Would be curious what the outbound request looks like. What's the second network request? Doesn't look like anything that EpubPress requests.

This is what the output should look like:

image

And the Headers:

image

haroldtreen commented 7 years ago

Published a new version of epub-press-js that catches this error and returns something nicer.

https://www.npmjs.com/package/epub-press-js

Now just need to update the chrome extension.

jeffrechten commented 7 years ago

@haroldtreen I noticed that the request was getting caught by a corporate proxy so that is why it wasn't making it to the server side.