zsrobinson / musescore-pdf

Convert any Musescore link into a printable PDF
MIT License
10 stars 4 forks source link

Time out #2

Open nomily opened 4 months ago

nomily commented 4 months ago

Hi! I followed the instructions and the homepage loads properly, but I keep getting a timeout issue... " An Unexpected Error Has Occurred Please double check the URL you submitted and your network connection. Error Message: Timed out after waiting 30000ms "

This happens both with sheets of my choosing, and with example sheets you suggest on the homepage.

Is there anything I'm missing?

zsrobinson commented 4 months ago

Hey there, I'm sorry you ran into this! I just tried cloning the project and wasn't able to reproduce the issue you're running into. That being said, I definitely remember running into something similar during development--it's something to do with puppeteer not being able to load the page correctly.

const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.goto(url, { waitUntil: "domcontentloaded" });
await new Promise((r) => setTimeout(r, 500));

Here's the code (also shown above) that actually calls on puppeteer to load the page. We have it wait until the dom is loaded, which more or less means that all of the html elements on the page have been loaded in and scripts have been run. More specifically, I'm pretty sure that the error you're getting is from the call to page.goto, which could be verified if the error message also displays in your terminal.

Without anymore specific details it's hard for me to know what's causing this timeout. I'd always try running the project from another device if possible, as well as making sure there's nothing funky going on with the network setup on your machine (although if you're able to visit the website manually then it's weird for puppeteer to have a problem with it).

I hope I've at least given you a good point to start off with troubleshooting this problem if it's still giving you trouble!

antoinedelplace commented 3 months ago
Internal error: TimeoutError: Timed out after waiting 30000ms
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\puppeteer\common\util.js:289:19
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:3986:35
    at OperatorSubscriber2._this._next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1055:13)
    at Subscriber2.next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:678:16)
    at AsyncAction2.<anonymous> (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:4863:24)
    at AsyncAction2._execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1974:16)
    at AsyncAction2.execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1963:26)
    at AsyncScheduler2.flush (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:2235:30)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "2121055795"
 ? Internal error: TimeoutError: Timed out after waiting 30000ms
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\puppeteer\common\util.js:289:19
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:3986:35
    at OperatorSubscriber2._this._next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1055:13)
    at Subscriber2.next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:678:16)
    at AsyncAction2.<anonymous> (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:4863:24)
    at AsyncAction2._execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1974:16)
    at AsyncAction2.execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1963:26)
    at AsyncScheduler2.flush (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:2235:30)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "2121055795"
 GET /generate?url=https%3A%2F%2Fmusescore.com%2Fuser%2F34495322%2Fscores%2F6089578 200 in 33153ms
antoinedelplace commented 3 months ago

This seems to work fine. The error is triggered after.

console.log("url", url)
let response = await page.goto(url, { waitUntil: "domcontentloaded", timeout: 0 });
let status = response?.status();
console.log("status", status)
url https://musescore.com/user/34495322/scores/6089578
status 200
antoinedelplace commented 3 months ago

The problem comes from this line in url-to-pdf.ts :

return await page.pdf({ format: "A4", scale });
antoinedelplace commented 3 months ago
return await page.pdf({ format: "A4", scale, timeout: 0 });

Adding timeout option like this gives me :

 ProtocolError: Page.printToPDF timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
    at async urlToPDF (./lib/url-to-pdf.ts:28:12)
    at async Promise.all (index 0)
    at async generate (./lib/generate.ts:25:18)
    at async Page (./app/generate/page.tsx:20:39)
digest: "2426683256"
 ? ProtocolError: Page.printToPDF timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
    at async urlToPDF (./lib/url-to-pdf.ts:28:12)
    at async Promise.all (index 0)
    at async generate (./lib/generate.ts:25:18)
    at async Page (./app/generate/page.tsx:20:39)
digest: "2426683256"
pamodm commented 2 months ago

I'm encountering the exact timeout issue

⨯ Internal error: TimeoutError: Timed out after waiting 30000ms
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\puppeteer\common\util.js:289:19
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:3986:35
    at OperatorSubscriber2._this._next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1055:13)
    at Subscriber2.next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:678:16)
    at AsyncAction2.<anonymous> (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:4863:24)
    at AsyncAction2._execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1974:16)
    at AsyncAction2.execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1963:26)
    at AsyncScheduler2.flush (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:2235:30)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3449646195"
 ⨯ Internal error: TimeoutError: Timed out after waiting 30000ms
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\puppeteer\common\util.js:289:19
    at ~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:3986:35
    at OperatorSubscriber2._this._next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1055:13)
    at Subscriber2.next (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:678:16)
    at AsyncAction2.<anonymous> (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:4863:24)
    at AsyncAction2._execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1974:16)
    at AsyncAction2.execute (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1963:26)
    at AsyncScheduler2.flush (~\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:2235:30)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3449646195"
 GET /generate?url=https%3A%2F%2Fmusescore.com%2Fuser%2F79422556%2Fscores%2F12141019 200 in 37169ms
AdLibML commented 1 week ago

Same here :

 ⨯ Internal error: TimeoutError: Timed out after waiting 30000ms
    at C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\puppeteer\common\util.js:289:19
    at C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:3986:35
    at OperatorSubscriber2._this._next (C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1055:13)
    at Subscriber2.next (C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:678:16)
    at AsyncAction2.<anonymous> (C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:4863:24)
    at AsyncAction2._execute (C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1974:16)
    at AsyncAction2.execute (C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:1963:26)
    at AsyncScheduler2.flush (C:\Users\garyj\musescore-pdf\node_modules\puppeteer-core\lib\cjs\third_party\rxjs\rxjs.js:2235:30)
    at listOnTimeout (node:internal/timers:594:17)
    at process.processTimers (node:internal/timers:529:7)
digest: "1934897524"
 GET /generate?url=https%3A%2F%2Fmusescore.com%2Fuser%2F19710%2Fscores%2F33816 200 in 32694ms