question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack optimize CanvasTest error

See original GitHub issue

Hi, first thanks for your work.

I just tried it, and if I specify in webpack.config.js :

module.exports = {
    optimization: {
        minimize: true,
        minimizer: [new TerserPlugin(),
    },
...

This error is thrown :

Uncaught ReferenceError: canvasTest is not defined
    at onmessage (d6ce07e3-5a07-454b-9558-b3c8698cbe7a:4)

I just test this code :

canvasSize.maxArea({
    usePromise: true,
    useWorker : true,
})
    .then(({ width, height, benchmark }) => {
        console.log(`Success: ${width} x ${height} (${benchmark} ms)`);
    })
    .catch(({ width, height, benchmark }) => {
        console.log(`Error: ${width} x ${height} (${benchmark} ms)`);
    });

Did I miss something ?

Best regards

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jhildenbiddlecommented, Nov 12, 2020

Hey again, @nicoja.

Fixed in 1.2.1.

Turned out to be an issue with Terser’s mangle option. Disabling this option or reserving the canvasTest name in the Terser config resolves the issue. If you’re still having issues, let me know.

Thanks!

1reaction
jhildenbiddlecommented, Nov 7, 2020

Very interesting. Also, very confusing.

  • The error occurs in Chrome 69 and later on the desktop (tested on macOS & Windows)
  • The error does not occur in the latest version of Chrome (86) when
    • … bundled via Parcel on codesandbox.io: https://c23pn.csb.app/
    • … when testing in headless mode (tested on macOS & Linux)

The reason I didn’t se the issue is because I hadn’t tested using Chrome on the desktop. Instead, I tested everything but that: using Safari on the desktop, using Chrome in headless mode via automated tests, and with sample code on codesandbox.io. 🤦

Looks like I’ll need to dive into this a bit more. Thanks for your patience!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimization - webpack
Use the optimization.emitOnErrors to emit assets whenever there are errors while compiling. This ensures that erroring assets are emitted. Critical errors are ...
Read more >
Webpack build error - Stack Overflow
I'm using exactly the same plugins on my webpack production config as you, and I'm quite sure that the reason is one of...
Read more >
runtime error when use webpack 5 with optimization ... - GitHub
Reproduction simple demo use webpack 5 and esbuild-webpack-plugin git clone https://github.com/diem98/webpack5-esbuild-demo.git git checkout ...
Read more >
Flaky WebGL Conformance Test: drawingbuffer-static-canvas ...
conformance/canvas/drawingbuffer-static-canvas-test.html (16 of 17 passed) failed: gl. ... I'll submit a bug for this and provide a patch for webkit.
Read more >
Webpack + React Optimised from scratch | Nerd For Tech
Now are ready with our basic setup now and I can't wait to watch it running. > npm run dev. ERROR in main...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found