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

Canvas dependency is too big to deploy on Vercel #37

Open
kdubb1337 opened this issue Feb 10, 2023 · 1 comment
Open

Canvas dependency is too big to deploy on Vercel #37

kdubb1337 opened this issue Feb 10, 2023 · 1 comment

Comments

@kdubb1337
Copy link

kdubb1337 commented Feb 10, 2023

As you can see from the screenshot, canvas alone is taking up more than 90% of the allowed size of Vercel's serverless functions. Would suggest moving to something more lightweight like: https://www.npmjs.com/package/@napi-rs/canvas

Vercel error

CleanShot 2023-02-09 at 21 12 45

My Serverless function

import { NextApiRequest, NextApiResponse } from 'next'
import nextConnect from 'next-connect'
import QRCode from 'easyqrcodejs-nodejs'

const handler = nextConnect().get(async (req: NextApiRequest, res: NextApiResponse) => {
  const options = {
    width: 400,
    height: 400,
    text: 'https://example.com',
    dotScale: 0.9,
  }

  const qrcode = new QRCode(options)
  const base64Data = (await qrcode.toDataURL()).replace('data:image/png;base64,', '')
  const img = Buffer.from(base64Data, 'base64')

  res.setHeader('Content-Type', 'image/png')
  res.setHeader('Content-Length', img.length)
  res.send(img)
})

export default handler
@0xAnthony
Copy link

Completely agree, same issue for deploying on any lambda, Canvas alone take all the free space

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