ignoreJSErrors true, yet puppeteer throws in some cases.
See original GitHub issue##Expected Behavior
When ignoreJSErrors is true
to get a minimal css result.
Current Behavior
minimalcss throws an exception.
Steps/Code to Reproduce
const minimalcss = require('minimalcss')
let options = {
urls: ["https://hostchefs.eu"],
enableServiceWorkers: false,
ignoreCSSErrors: true,
ignoreJSErrors: true,
ignoreRequestErrors: true,
puppeteerArgs: ['--no-sandbox'],
};
minimalcss.minimize(options)
.then(result => {
console.log( result.finalCss )
})
.catch(error => {
console.log(`Oups: ${error}`)
process.exit(1)
})
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
ignoreHTTPSErrors is not working when request interception ...
I have '--ignore-certificate-errors' in arguments and ignoreHTTPSErrors is TRUE, but receive ERR_CERT_AUTHORITY_INVALID error from Chromium.
Read more >puppeteer throw error "UnhandledPromiseRejectionWarning ...
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not...
Read more >Troubleshooting - Puppeteer
The most common cause is a bug in Node.js v14.0.0 which broke extract-zip , the module Puppeteer uses to extract browser downloads into...
Read more >[Node] js agent and puppeteer background transaction throws ...
We want to use background transaction to instrument background PDF report generation with puppeteer. It throws an error: TypeError: Cannot ...
Read more >Handling those unhandled promise rejections with JS async ...
The await ed function fails (i.e. rejects a promise); You throw an error in the catch block to terminate the script; You get...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
By the way, there’s something really wrong about that
response.css
by the way. I get an error trying to runprettier --write response.css
which means it can’t parse it either.This happens. We (CSS files) all make mistakes. I just wish the error wasn’t so cryptic. I’d love it if
minimalcss
could throw a helpful error like:Do you think you can take a look at that? I suspect what happens is that
minimalcss
correctly manages to parse it but, when you try to usecsso.syntax.compress(ast)
it fails.In fact, this diff kinda solves your problem:
Obivously, that’s not good enough for a fix. But might be a start. At least, equipped with something like this you’d get an insight where to put your attention (
responsive.css
in your case).Also, remember that you can potentially move this code down into the bottom of the file where you have an Object (
stylesheetAsts
) that maps each URL to an AST.Perhaps something like
--debug-css-urls
could kick in some extra code that scrutinizes each AST like this. Do you think you can take a look at that? If you get stuck, I can help write a unit test.I dumped all the CSS it downloads to a temp directory:
In
response.css
you have this:And I put some
console.log
in node_modules/csso/lib/restructure/4-restructShorthand.js:81 and print thedeclaration
whendeclaration.value.children === undefined
and it prints:So when theres a mention of
55px width:50%
it croaks. And that’s mentioned in your CSS validator too.Now, I wish we can turn this into a bug on
csso
andcss-tree
because it shouldn’t crash if you have invalid CSS. At least not this late.