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

Fix broken Puppeteer upgrade to version 13.0.0 #14363

Closed
timvandermeij opened this issue Dec 11, 2021 · 6 comments · Fixed by #14368
Closed

Fix broken Puppeteer upgrade to version 13.0.0 #14363

timvandermeij opened this issue Dec 11, 2021 · 6 comments · Fixed by #14368

Comments

@timvandermeij
Copy link
Contributor

The Puppeteer development dependency is now pinned to version 12.0.1 because version 13.0.0 fails for (to us) unknown reasons since nothing really stands out in the 13.0.0 changelogs. It's strange because everything about the new release works, except for one integration test ("must change colors") on one platform (Windows) with the following traceback:

Failures:
1) Interaction in js-colors.pdf must change colors
  Message:
    ProtocolError: Protocol error (Runtime.callFunctionOn): Debugger: expected Debugger.Object, got Proxy _returnError@chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm:185:22
    callFunctionOn@chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm:260:23

  Stack:
    error properties: Object({ originalMessage: 'Debugger: expected Debugger.Object, got Proxy' })
    ProtocolError: Protocol error (Runtime.callFunctionOn): Debugger: expected Debugger.Object, got Proxy _returnError@chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm:185:22
    callFunctionOn@chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm:260:23
        at C:\pdfjs\botio-files-pdfjs\private\6f70ec10008fe96\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:226:24
        at new Promise (<anonymous>)
        at CDPSession.send (C:\pdfjs\botio-files-pdfjs\private\6f70ec10008fe96\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:222:16)
        at ExecutionContext._evaluateInternal (C:\pdfjs\botio-files-pdfjs\private\6f70ec10008fe96\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:204:50)
        at ExecutionContext.evaluateHandle (C:\pdfjs\botio-files-pdfjs\private\6f70ec10008fe96\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:155:21)
        at WaitTask.rerun (C:\pdfjs\botio-files-pdfjs\private\6f70ec10008fe96\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:547:41)
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)

Maybe someone with Windows can try to reproduce this and find out what is special about the "must change colors" test that triggers this. Once we know what causes it, we can either fix it, or work around it and file an upstream bug report.

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Dec 12, 2021

Now that the integration tests on Linux work again, I found that the same test permafails on Linux as well with Puppeteer 13, but fortunately with a more helpful stack trace than the one above from Windows:

1) Interaction in js-colors.pdf must change colors
  Message:
    Error: Evaluation failed: DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDocument]' is not a valid selector.
        at eval (eval at waitForPredicatePageFunction (:3:23), <anonymous>:4:45)
        at eval (eval at waitForPredicatePageFunction (:3:23), <anonymous>:5:28)
        at onRaf (__puppeteer_evaluation_script__:50:35)
        at pollRaf (__puppeteer_evaluation_script__:43:15)
        at waitForPredicatePageFunction (__puppeteer_evaluation_script__:8:22)
  Stack:
    Error: Evaluation failed: DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDocument]' is not a valid selector.
        at eval (eval at waitForPredicatePageFunction (:3:23), <anonymous>:4:45)
        at eval (eval at waitForPredicatePageFunction (:3:23), <anonymous>:5:28)
        at onRaf (__puppeteer_evaluation_script__:50:35)
        at pollRaf (__puppeteer_evaluation_script__:43:15)
        at waitForPredicatePageFunction (__puppeteer_evaluation_script__:8:22)
        at ExecutionContext._evaluateInternal (/home/timvandermeij/Documenten/Ontwikkeling/pdf.js/Code/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async WaitTask.rerun (/home/timvandermeij/Documenten/Ontwikkeling/pdf.js/Code/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:547:27)

Given this information I'm on the fence if this is actually a Puppeteer 13 bug, or just a mistake in our test that just happens to surface in Puppeteer 13...

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Dec 12, 2021

If I remove https://github.com/mozilla/pdf.js/blob/master/test/integration/scripting_spec.js#L699-L707 the test passes under Puppeteer 13. I see this was added in 17363bb to fix another issue. The error seems to indicate that the argument passed to querySelector is the document object instead of the ref variable somehow, looking at issues like puppeteer/puppeteer#4708.

@timvandermeij
Copy link
Contributor Author

Lo and behold: _ref in the code fragment above actually refers to the document object now in Puppeteer 13. It looks like the arguments are shifted because the _current argument (the next one) now refers to what _ref used to refer to. At the very least we now know something changed in Puppeteer and looking at the documentation this seems like a bug.

@timvandermeij
Copy link
Contributor Author

I'll try to reduce this for an upstream bug since the documentation doesn't indicate this behavior and the changelogs also don't mention any changes here, so I strongly suspect an upstream regression. Fortunately I do think we can fix it on our side too; I'll try that out later today.

@timvandermeij
Copy link
Contributor Author

I have created a minimal reproducer and filed puppeteer/puppeteer#7836 upstream since this is in fact a regression in Puppeteer 13.

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Dec 15, 2021

Follow-up: it looks like our reported regression got fixed upsteam now in puppeteer/puppeteer#7845, so hopefully in a next Puppeteer release this won't be a problem anymore for new code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant