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.

RangeError: Maximum call stack size exceeded when using esbuild-node-externals plugin

See original GitHub issue

When using esbuild-node-externals plugin there is a recursive function that runs out of stack space.

esbuild-plugins.js

const graphqlLoaderPlugin = require('@luckycatfactory/esbuild-graphql-loader').default;
const { nodeExternalsPlugin } = require('esbuild-node-externals');

module.exports = [graphqlLoaderPlugin(), nodeExternalsPlugin()];
esbuild config

serverless.yml

esbuild:
  packager: yarn
  plugins: ./esbuild-plugins.js
  minify: false
  keepNames: true
  sourcemap: true
  sourcesContent: false
  exclude:
    - mysql
Serverless: Packing external modules: @aws-sdk/client-apigatewaymanagementapi@^3.33.0, @aws-sdk/client-dynamodb@^3.31.0, @aws-sdk/util-dynamodb@^3.33.0, @lambda-middleware/cors@^2.0.0, @sendgrid/client@^7.4.6, @sendgrid/mail@^7.4.6, JSONStream@^1.3.5, airtable@^0.10.1, apollo-server-lambda@^2.25.2, graphql@^15.5.3, apollo-server-plugin-base@^0.13.0, aws-lambda-graphql@1.0.0-alpha.23, graphql-subscriptions@^1.2.1, axios@^0.21.4, axios-logger@^2.5.0, compare-versions@^3.6.0, cors@^2.8.5, dataloader@^2.0.0, express@^4.17.1, fp-ts@^2.11.2, google-libphonenumber@^3.2.22, graphql-depth-limit@^1.1.0, graphql-request@^3.4.0, graphql-scalars@^1.10.1, ini@^1.3, io-ts@^2.2.16, io-ts-promise@^2.0.2, jsonwebtoken@^8.5.1, jwk-to-pem@^2.0.5, jwks-rsa@^2.0.4, knex@^0.95.11, knex-stringcase@^1.4.5, luxon@^2.0.2, mysql2@^2.3.0, parse-duration@^1.0.0,  qs@^6.10.1, serverless-http@^2.7.0, source-map-support@^0.5.20, states-us@^1.0.1, timezones-list@^3.0.1, twilio@^3.68.0, uuid@^8.3.2, vm2@^3.9.3
 
 Range Error ---------------------------------------------
 
  RangeError: Maximum call stack size exceeded
      at flatDep (/home/nhoize/vori/voyaapollolambda/node_modules/serverless-esbuild/dist/helper.js:57:17)
      at /home/nhoize/vori/voyaapollolambda/node_modules/serverless-esbuild/dist/helper.js:68:75
      at Array.reduce (<anonymous>)
      at flatDep (/home/nhoize/vori/voyaapollolambda/node_modules/serverless-esbuild/dist/helper.js:63:33)
      at /home/nhoize/vori/voyaapollolambda/node_modules/serverless-esbuild/dist/helper.js:68:75
      at Array.reduce (<anonymous>)
      at flatDep (/home/nhoize/vori/voyaapollolambda/node_modules/serverless-esbuild/dist/helper.js:63:33)
      at /home/nhoize/vori/voyaapollolambda/node_modules/serverless-esbuild/dist/helper.js:68:75
      at Array.reduce (<anonymous>)

…repeats for another 14,000 lines

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

1reaction
clementACcommented, Apr 5, 2022

yes I edited the stacktrace XXX is not the version in package.json =).

Good catch, when I switch the lines it works!

1reaction
clementACcommented, Apr 5, 2022

yes sure

StackTrace

serverless package --stage=$npm_config_stage

Serverless: Compiling to node14 bundle with esbuild...
Serverless: Compiling with concurrency: Infinity
Serverless: Compiling completed.
Serverless: Package lock found - Using locked versions
Serverless: Packing external modules: @prisma/client@XXX, @sentry/node@XXX, apollo-server-lambda@XXX, graphql@XXX, date-fns@^XXX, email-validator@^XXX, graphql-type-json@^XXX, ip-address@^XXX, jsonschema@^XXX, knex@^XXX, nanoid@XXX, node-fetch@^XXX, p-limit@^XXX, papaparse@^XXXX, pg@^XXX, prisma-query-log@^XXX, sanitize-html@^XXX, serverless-sentry-lib@^XXX, slugify@^XXX, source-map-support@^XXX, stripe@^WWW, ts-retry-promise@^WWW, uuid@^XXX, winston@^XXX, winston-console-format@^XXX
 
 Range Error ---------------------------------------------
 
  RangeError: Maximum call stack size exceeded
      at /pathToProject/node_modules/serverless-esbuild/dist/helper.js:75:38
      at Array.forEach (<anonymous>)
      at recursiveFind (/pathToProject/node_modules/serverless-esbuild/dist/helper.js:75:30)
      at /pathToProject/node_modules/serverless-esbuild/dist/helper.js:83:17
      at Array.forEach (<anonymous>)
      at recursiveFind (/pathToProject/node_modules/serverless-esbuild/dist/helper.js:75:30)
      at /pathToProject/node_modules/serverless-esbuild/dist/helper.js:83:17
      at Array.forEach (<anonymous>)
      at recursiveFind (/pathToProject/node_modules/serverless-esbuild/dist/helper.js:75:30)
      at /pathToProject/node_modules/serverless-esbuild/dist/helper.js:83:17
      at Array.forEach (<anonymous>)
.............
............. lot of same lines
.............
      at recursiveFind (/pathToProject/node_modules/serverless-esbuild/dist/helper.js:75:30)
      at flatDep (/pathToProject/node_modules/serverless-esbuild/dist/helper.js:92:5)
      at /pathToProject/node_modules/serverless-esbuild/dist/pack.js:140:49
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async Promise.all (index 0)
      at async EsbuildServerlessPlugin.pack (/pathToProject/node_modules/serverless-esbuild/dist/pack.js:129:5)
      at async before:package:createDeploymentArtifacts (/pathToProject/node_modules/serverless-esbuild/dist/index.js:86:17)
      at async PluginManager.runHooks (/pathToProject/node_modules/serverless/lib/classes/PluginManager.js:601:35)
      at async PluginManager.invoke (/pathToProject/node_modules/serverless/lib/classes/PluginManager.js:638:9)
      at async PluginManager.run (/pathToProject/node_modules/serverless/lib/classes/PluginManager.js:700:7)
      at async Serverless.run (/pathToProject/node_modules/serverless/lib/Serverless.js:468:5)
      at async /pathToProject/node_modules/serverless/scripts/serverless.js:836:9

I removed all circular dependencies detected by tools sush as magde or dpdm and everything is clean.

Serverless.yml

esbuild:
    bundle: true
    minify: true
    sourcemap: false
    keepNames: true
    exclude: ['aws-sdk', 'pg-native']
    plugins: plugins.js
....
package:
  patterns:
     #this is from prisma library recomandation
    - '!node_modules/.prisma/client/libquery_engine-*'
    - 'node_modules/.prisma/client/libquery_engine-rhel-*'
    - '!node_modules/prisma/libquery_engine-*'
    - '!node_modules/@prisma/engines/**'
  individually: true
Read more comments on GitHub >

github_iconTop Results From Across the Web

Maximum call stack size exceeded when using esbuild-node ...
When using esbuild-node-externals plugin there is a recursive function that runs out of stack space. esbuild-plugins.js
Read more >
Maximum call stack size exceeded on npm install
Maximum call stack size exceeded on npm install · 1. First of all, I'd check the github issues link for similar problems, and...
Read more >
[BUG] npm audit fix error: Maximum call stack size exceeded
Assuming that "Maximum call stack size exceeded" happens because there is too much to do, it may be that the reproducer is really...
Read more >
Node.js Agent version 3.x - Elastic
Avoid a possible RangeError: Maximum call stack size exceeded in Span timer handler for exceedingly deep Span trees. (#2939); Fix instrumentation of (very ......
Read more >
crim-adnotare-psc - npm Package Health Analysis - Snyk
Ensure you're using the healthiest npm packages ... fork-ts-checker-webpack-plugin ... RangeError: Maximum call stack size exceeded ...
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