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

UnhandledPromiseRejectionWarning: TypeError: parse is not a function #505

Open
priyatham19 opened this issue Jun 16, 2021 · 0 comments
Open

Comments

@priyatham19
Copy link

priyatham19 commented Jun 16, 2021

We have been using critical package to generate critical css for our Next JS application. Now we are getting the following error.

UnhandledPromiseRejectionWarning: TypeError: parse is not a function
at compileUnsafe (D:--path--\node_modules\css-select\lib\compile.js:31:14)
at select (D:--path--\node_modules\css-select\index.js:18:49)
at CSSselect (D:--path--\node_modules\css-select\index.js:41:9)
at initialize.exports.find (D:--path--\node_modules\cheerio\lib\api\traversing.js:40:21)
at initialize.module.exports (D:--path--\node_modules\cheerio\lib\cheerio.js:86:18)
at new initialize (D:--path--\node_modules\cheerio\lib\static.js:29:20)
at initialize (D:--path--\node_modules\cheerio\lib\static.js:26:14)
at oust (D:--path--\node_modules\oust\index.js:72:37)
at Function.module.exports.raw (D:--path--\node_modules\oust\index.js:98:37)
at getStylesheetHrefs (D:--path--\node_modules\critical\src\file.js:370:28)
(node:18364) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18364) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

We have written a custom script to fetch the HTML file path and generate for each HTML. This is a sample of code snippent.

critical.generate({
base: './',
src: files[i], // files array has list of all the files and we are looping through the array
target: files[i],
minify: true,
inline: true,
dimensions: [{
width: 414,
height: 736
}, {
width: 768,
height: 1024
}, {
height: 900,
width: 1200,
}],
ignore: ['@font-face']
},(err, output) => {
if(err) {
console.info(Critical css generation failed ${err})
}
else if(output) {
console.info(${i} success: ${files[i]} [critical css generated])
}
})

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

1 participant