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

Error: Evaluation failed: DOMException: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules at _ (__puppeteer_evaluation_script__:4:20) #157

Closed
pat-s opened this issue Jul 24, 2018 · 14 comments

Comments

@pat-s
Copy link

pat-s commented Jul 24, 2018

On some local html I get the following error with v2.8.5 while v2.8.0 works:

Error: Evaluation failed: DOMException: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules
    at _ (__puppeteer_evaluation_script__:4:20)

I cannot reproduce this locally with an example presentation. Using their online version works.

I used the docker approach.

@astefanutti
Copy link
Owner

Would you be able to share a reproducer? If not, could you provide the complete stack trace and the presentation framework you use?

It may be due to more restrictive security constraints introduced in newer version of Chrome.

@pat-s
Copy link
Author

pat-s commented Jul 31, 2018

reprex.zip

If I call the docker approach on slides that are hosted online, both 2.8.0 AND 2.8.5 are working

docker run --rm -t -v `pwd`:/slides -v $HOME:$HOME astefanutti/decktape:2.8.5 https://pjs-web.de/files/basis_descriptive.html ~/Downloads/test.pdf

Loading page https://pjs-web.de/files/basis_descriptive.html ...
Failed to load resource: the server responded with a status of 404 ()
Failed to load resource: the server responded with a status of 404 ()
Loading page finished with status: 200
Remark JS plugin activated
Printing slide #2       (2/2) ...
Printed 2 slides

If I execute the same statement on a local file, I get:

docker run --rm -t -v `pwd`:/slides -v $HOME:$HOME astefanutti/decktape:2.8.5 ~/Downloads/basis_descriptive.html ~/Downloads/test.pdf

Loading page file:///home/pjs/Downloads/basis_descriptive.html ...

Unable to load resource from URL: file:///home/_setup/css/xaringan-theme.css
Failed to load resource: net::ERR_FILE_NOT_FOUND
Unable to load resource from URL: file:///home/_setup/css/tweaks.css
Failed to load resource: net::ERR_FILE_NOT_FOUND
Loading page finished with status: 0
Remark JS plugin activated

Error: Evaluation failed: DOMException: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules
    at _ (__puppeteer_evaluation_script__:4:20)

Ignore the warnings about the missing CSS files there. But its interesting that both versions react in a different way to the missing CSS files (not shown here).

@astefanutti
Copy link
Owner

Thanks for the reproducer. I confirm I can reproduce.

It seems Chromium 64+ forbids the browser from accessing CSS rules for cross-domain sheets, which is what the Remark plugin does to adjust PDF export and that triggers the error while loading the presentation from the locally.

I'm still trying to find the best strategy to deal with that new constraint...

@astefanutti
Copy link
Owner

It should be fixed with 272b702 that ships with 2.8.6 release.

@siddhantgoel
Copy link

I'm running into the same issue when trying to export a remarkjs presentation.

I've tried adding the --allow-file-access-from-files arg as mentioned in the errors section in the README but the error still persists.

I'm using decktape version 2.8.9, and Chromium 70.0.3538.67 (Arch Linux).

@astefanutti
Copy link
Owner

The --chrome-arg option, as documented in the README, has been introduced in Decktape version 2.9.0. That being said, the --allow-file-access-from-files option flag was set by default in version 2.8.9.

It's not clear why that would fail even with the --allow-file-access-from-files option flag. As any Chrome option can be passed with the --chrome-arg option in version 2.9.0, you could upgrade your version of Decktape and try with the --disable-web-security option flag.

@siddhantgoel
Copy link

My bad, I saw the 2.8.9 npm badge and thought the documentation is for that version.

How can I install 2.9.0? yarn add 2.9.0 does not show 2.9.0 in the list of available versions. Thanks for your help!

@astefanutti
Copy link
Owner

It's my bad actually, I completely forgot to publish the new version 🙃! It should be published now.

@siddhantgoel
Copy link

No worries, 2.9.0 seems to work! 🎉

@pat-s
Copy link
Author

pat-s commented Oct 22, 2018

How can I install 2.9.0?

There is also an AUR package nodejs-decktape :)

@siddhantgoel
Copy link

There's always an AUR package. :)

@ahmadawais
Copy link

It's again not working in the v2.9.2 :(

@astefanutti
Copy link
Owner

@ahmadawais have you tried with the --chrome-arg=--allow-file-access-from-files option flag, or --chrome-arg=--disable-web-security?

@ahmadawais
Copy link

I ran with decktape remark https://wordsesh2019.ahmadawais.com/ slide.pdf --chrome-arg=--disable-web-security

And that worked. Mention this in the readme as well. --chrome-arg=--allow-file-access-from-files didn't work.

sunny added a commit to sunny/decktape that referenced this issue Mar 30, 2020
astefanutti pushed a commit that referenced this issue Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants