Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

[showcase] Investigating max-old-space-size settings #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kelvintaywl
Copy link
Owner

@kelvintaywl kelvintaywl commented Oct 21, 2021

Description

This PR is to showcase the oddity when we set max-old-space-size for Node, via NODE_OPTIONS, when running sls commands.
Mainly, when using the installed sls standalone binary (via ServerlessFramework orb), we see an odd exit code 4, with this stacktace:

(node:100) WARNING: Exited the environment with code 4
    at exit (internal/process/per_thread.js:172:13)
    at _compile (pkg/prelude/bootstrap.js:1429:29)
    at Module._extensions..js (internal/modules/cjs/loader.js:1218:10)
    at Module.load (internal/modules/cjs/loader.js:1047:32)
    at Module._load (internal/modules/cjs/loader.js:935:14)
    at Module.require (internal/modules/cjs/loader.js:1087:19)
    at require (pkg/prelude/bootstrap.js:1338:31)
    at require (internal/modules/cjs/helpers.js:73:18)
    at /snapshot/serverless/lib/classes/Variables.js:7:20
    at _compile (pkg/prelude/bootstrap.js:1433:22)

Exited with code exit status 4

Looking at that stacktrace, it seems to be a pkg issue.
From what I can gather, the sls binary installed by CircleCI's ServerlessFramework is done as a standalone binary.

I believe ServerlessFramework CLI uses Vercel's pkg tool to package the CLI.

From existing GitHub issues, there seem to be unresolved cases of pkg exiting on exit code 4.

In particularly, this comment from a GitHub user seems to explain the situation, but not the solution:
vercel/pkg#921 (comment)

Solution

Hence, I provided an alternative to deploying, should you need to explicitly set max-old-space-size when deploying with sls.
The solution is basically to forgo the sls standalone binary for now (i.e., not using the ServerlessFramework orb), and explicitly install the ServerlessFramework CLI via NPM and AWS CLI instead.

You can see the differences in this PR's CI build status:

Workflow Job Build Status Spec
main serverless-deploy-1 see build NODE_OPTIONS:--max-old-space-size=4096, use ServerlessFramework Orb
alternative serverless-deploy-2 see build NODE_OPTIONS:--max-old-space-size=4096, install ServerlessFramework CLI ourselves

Screen Shot 2021-10-21 at 11 24 08

@kelvintaywl kelvintaywl force-pushed the showcase/bug-when-set-max-old-space-size branch from 2e1fee2 to 862d708 Compare October 21, 2021 01:21
@kelvintaywl kelvintaywl force-pushed the showcase/bug-when-set-max-old-space-size branch from 61ebaf4 to e5a0d1d Compare October 21, 2021 01:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant