Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems downloading docs in chrome, with recap enabled... #352

Closed
el-abcd opened this issue Sep 29, 2023 · 5 comments · Fixed by freelawproject/recap-chrome#348
Closed
Assignees

Comments

@el-abcd
Copy link

el-abcd commented Sep 29, 2023

Summary:
Get a spinning beach ball in chrome on mac when trying to download docs with recap enabled.

Details:
While it appears that recap can successfully upload the docket (when I view it in pacer, using chrome with the recap extension), the last several times (over a couple weeks, I'm an occasional user) that I have tried to download docs from the dockets I am interested in (CA bankruptcy court) the downloads to NOT complete (spinning beach ball).

Example docket I'm trying to download from:
https://www.courtlistener.com/docket/67784556/the-litigation-practice-group-pc-adversary-proceeding/
https://ecf.cacb.uscourts.gov/cgi-bin/DktRpt.pl?759118030653799-L_1_0-1

Note: the one I'm reporting this bug on is a 6 part document (I wonder if this is related to multi-part documents)...
Screenshot 2023-09-29 at 12 33 53 PM

The "solution" for me has been to disable the recap extension, then the downloads work as expected.

When I open the developer tools and look at the console messages I see the following:
RECAP: Successfully submitted zip file request
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'src')
at extractUrl (content_delegate.js:548:22)
at ContentDelegate.onDownloadAllSubmit (content_delegate.js:592:18)

So, somewhere in here:

// fetch the html page which contains the <iframe> link to the zip document.
const htmlPage = await browserSpecificFetch(event.data.id).then((res) => res.text());
console.log('RECAP: Successfully submitted zip file request');
const zipUrl = extractUrl(htmlPage);
//download zip file and save it to chrome storage
const blob = await fetch(zipUrl).then((res) => res.blob());
const dataUrl = await blobToDataURL(blob);
console.info('RECAP: Downloaded zip file');
// save blob in storage under tabId
// we store it as an array to chunk the message
await updateTabStorage({
[this.tabId]: { ['zip_blob']: dataUrl },
});

...

// TODO: Confirm that zip downloading is consistent across jurisdictions
ContentDelegate.prototype.onDownloadAllSubmit = async function (event) {
// helper function - extract the zip by creating html and querying the frame
const extractUrl = (html) => {
const page = document.createElement('html');
page.innerHTML = html;
const frames = page.querySelectorAll('iframe');
return frames[0].src;
};

@mlissner
Copy link
Member

Thanks for the useful bug report. @ERosendo can you please take a look at this when you have a moment away from the ACMS stuff and the Elastic stuff?

@el-abcd, you might be able to just disable uploading from within RECAP's settings. That puts it in "mooch mode" which I think would at least let you get content for free until this is fixed.

@el-abcd
Copy link
Author

el-abcd commented Sep 29, 2023

Thx.

I did try downloading the six docs above "one at a time" and that did work (clunky, end up opening multiple tabs, etc.).
But I think that might help confirm this is related to "multi-part docs". I'll try disabling uploads when I do more "multi-part" downloads.

The successfully uploaded docs (that I fetched one at a time) do show up here:
https://www.courtlistener.com/docket/67784556/the-litigation-practice-group-pc-adversary-proceeding/

@ERosendo ERosendo self-assigned this Oct 2, 2023
@ERosendo
Copy link

@mlissner Upon examination, the issue seems to be related to the extractUrl helper function. This function attempts to extract the zip URL from the response generated after the form is submitted. However, it employs a query to an iframe within the response, which fails in the absence of this HTML element (as encountered in docket 8:23-ap-01098).

I inspected the response received after the form submission and noticed it contained only a small number of HTML tags. The following is the body of the HTML page we get:

<div id="cmecfMainContent">
  <br>&nbsp;Your download will begin in a separate window.
  <div id="scroller" style="height: 100%; width: 100%; overflow: scroll; -webkit-text-size-adjust:none; resize: both;">
  <script language="javascript" type="text/javascript">
      window.location = "/cgi-bin/show_temp.pl?file=zipped_0.352834029679315.zip&type=application/zip&filename_prompt=8-23-ap-01098-SC.zip";
  </script>
</div>

I was able to download the zip file by using the URL embedded within the script tag. This suggests that we could fix this issue by tweaking the extractUrl to get the URL from the script tag

@el-abcd
Copy link
Author

el-abcd commented Nov 16, 2023

FWIW, this LGTM!

I forked the repo, git clone'd it locally, and followed the instructions on how to install locally for chrome (tweak versions in package.json and manifest.json, make the zip, and "load unpacked" in chrome.

I tested by downloading and uploading this multi-doc zip file:
https://www.courtlistener.com/docket/67051161/the-litigation-practice-group-pc/?filed_after=&filed_before=&entry_gte=&entry_lte=&order_by=desc#entry-511

and it worked as expected (including the message mentioning a download was in progress).

Thanks!
Eric

@mlissner
Copy link
Member

Thanks again for the helpful bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants