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

Cannot read properties of undefined (reading 'setOfflineMode') #38

Open
Viiprogrammer opened this issue Jun 11, 2022 · 1 comment
Open

Comments

@Viiprogrammer
Copy link

Viiprogrammer commented Jun 11, 2022

I am converting about 50 files in a loop, and about once every couple of hundred I get an error:

/home/righthaze/.../node_modules/svg-to-img/dist/index.js:58
    await page.setOfflineMode(true);
               ^

TypeError: Cannot read properties of undefined (reading 'setOfflineMode')
    at convertSvg (/home/.../node_modules/svg-to-img/dist/index.js:58:16)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /home/.../index.js:37:9

My code:

const svgToImg = require("svg-to-img")

for (let sample = 0; sample < 50000; sample++) {
  const samplePath = path.join(samplesPath, sample.toString())
  fs.mkdirSync(samplePath, { recursive: true })
  const { path: svgPath } = await mega.getCaptcha()
  const step = 1.0 / 50

  for (let i = 1.0; i > step; i = i - step) {
    let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="298" height="100" viewBox="0,0,298,100">`
    svg += `<path fill="none" stroke="black" d="${ calcCaptchaPath(i, svgPath) }"></path>`
    svg += `</svg>`
    await svgToImg.from(svg).toJpeg({
      path: path.join(samplePath, i.toString() + ".jpg")
    });
  }
  1. Node: v16.14.0
  2. OS: Ubuntu 20.04
  3. svg-to-img: 2.0.9
@anistark
Copy link

@etienne-martin Any resolution for the above?
Facing this on mac m1 as well. Node 18 using 2.0.9

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

2 participants