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.

Serverless Framework project fails to deploy because of archive size

See original GitHub issue

Bug description

Generated bundle of the Serverless project has too big size and exceeds allowed by AWS Lambda 250 MB. It happens because of big sizes of downloaded @prisma/client, which, for some reasons, downloads engines folder that has unzipped size of 96 MB. And the other big files are connected to generated using command prisma generate schema. image image image

Dependency versions

@prisma/client: “^2.20.0” prisma (dev) : “^2.20.1” serverless (dev): “^2.32.1” serverless-webpack: “^5.4.0” webpack: “^5.11.0” @types/webpack: “^4.41.25”

Webpack config

import nodeExternals from 'webpack-node-externals';
import slsw from 'serverless-webpack';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
import CopyPlugin from 'copy-webpack-plugin';

const isOffline = !!slsw.lib.webpack.isLocal;

if (isOffline) {
    // eslint-disable-next-line no-console
    console.log('Offline mode detected!');
}

// Add plugins for the offline mode here
const offlinePlugins: NonNullable<Configuration['plugins']> = [];

const config: Configuration = {
    target: 'node',
    entry: slsw.lib.entries,
    externals: [nodeExternals()],
    mode: isOffline ? 'development' : 'production',
    devtool: 'source-map',
    module: {
        rules: [
            {
                test: /\.ts$/,
                use: [
                    'source-map-loader',
                    {
                        loader: 'ts-loader',
                        options: {
                            onlyCompileBundledFiles: true,
                        },
                    },
                ],
            },
            {
                test: /\.graphql$/,
                use: ['raw-loader'],
            },
        ],
    },
    plugins: [
        ...(isOffline ? offlinePlugins : []),
        new CopyPlugin({
            patterns: [
                { from: './src/database/prisma/schema.prisma', to: './schema.prisma' },
            ],
        })],
    resolve: {
        plugins: [
            new TsconfigPathsPlugin(),
        ],
        extensions: ['.ts', '.js'],
    },
    optimization: {
        minimize: !isOffline,
    },
    stats: 'minimal',
};

export = config;

Serverless webpack options

    webpackConfig: webpack.config.ts
    includeModules: true
    packager: npm
    packagerOptions:
      scripts:
        - prisma generate

Environment

& setup

  • OS: Mac OS Big Sur 11.1
  • Database: PostgreSQL
  • Node.js version: 12
  • Prisma version: 2.20.1

Background

This is on the first deploy of Prisma to our existing Lambda stack. We have not been able to get Lambda working yet. We bundle our functions through webpack before deploying.

I have looked at the webpack bundle and confirm that @prisma/client is being bundled with the lambda function before deploying.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:55 (28 by maintainers)

github_iconTop GitHub Comments

4reactions
jswcommented, May 12, 2021

@janpio I created a minimum repro at https://github.com/jsw/prisma-issue-6644

Also, I fixed part of the issue by moving the packages.patterns from function scope to file scope, though both are supposed to work if I’m correctly following the serverless docs. Take a look at my serverless.yml. And @prisma/engines and prisma are still included unless your workaround above is applied.

4reactions
janpiocommented, Apr 19, 2021

Quick update: I can confirm that we upload both binaries, the native and the rhel one, in standard Serverless Framework projects. No Webpack required even. If your own application code is big, this can of course lead to upload (50MB limit) or unpack (150MB limit) problems. I’ll look for a solution and let you know again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 10 Serverless Deployment Errors (and How to Fix Them)
The most common error I see our users encounter is when a deploy fails because a previous deploy was unsuccessful. · This situation...
Read more >
AWS Lambda Guide - Serverless.yml Reference
Deployment bucket. Serverless Framework needs a S3 bucket to store artifacts for deploying. That bucket is automatically created and managed by Serverless, ...
Read more >
AWS Lambda Functions - Serverless Framework
Versioning Deployed Functions ... By default, the framework creates function versions for every deploy. This behavior is optional, and can be turned off...
Read more >
Python Requirements - Serverless Framework: Plugins
This will automatically add the plugin to your project's package.json and the ... $HOME/.ssh/known_hosts file, as the install process will fail otherwise ...
Read more >
Packaging - Serverless Framework
Using the Serverless CLI tool, you can package your project without deploying it to AWS. This is best used with CI / CD...
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