SOLVED: I had an errant `.csv` file in my app and...
# help
d
SOLVED: I had an errant
.csv
file in my app and that broke deployment because computers are complex I have a strange deployment error and can’t seem to make sense of it. 🧵
It looks like my
MyStack
tests are failing on creating a build for the React Site but it’s not obvious why.
Copy code
$ npm test
106.42 s
> comics-helper@0.1.0 test /tmp/seed/source
> sst test
Attention: SST now collects completely anonymous telemetry regarding usage. This is used to guide SST's roadmap.
You can learn more, including how to opt-out of this anonymous program, by heading over to:
<https://docs.serverless-stack.com/anonymous-telemetry>
Preparing your SST app
Mismatched versions of AWS CDK packages. Serverless Stack currently supports 2.7.0. Fix using:
  npm install @aws-cdk/core@2.7.0 --save-exact
  npm install @aws-cdk/assert@2.7.0 --save-dev --save-exact
Learn more about it here — <https://github.com/serverless-stack/serverless-stack#cdk-version-mismatch>
PASS test/getCustomDomain.spec.js
> frontend@0.1.0 build /tmp/seed/source/frontend
> craco build
Creating an optimized production build...
internal/child_process.js:403
    throw errnoException(err, 'spawn');
    ^
Error: spawn ENOMEM
    at ChildProcess.spawn (internal/child_process.js:403:11)
    at spawn (child_process.js:553:9)
    at fork (child_process.js:121:10)
    at ChildProcessWorker.initialize (/tmp/seed/source/frontend/node_modules/jest-worker/build/workers/ChildProcessWorker.js:141:45)
    at ChildProcessWorker._onExit (/tmp/seed/source/frontend/node_modules/jest-worker/build/workers/ChildProcessWorker.js:274:12)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:467:12)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
  errno: -12,
  code: 'ENOMEM',
  syscall: 'spawn'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 build: `craco build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frontend@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-01-22T00_42_42_146Z-debug.log
FAIL test/MyStack.test.js
  ● Test suite failed to run
    There was a problem building the "ReactSite" StaticSite.
      147 |     ]);
      148 |
    > 149 |     const reactApp = new sst.ReactStaticSite(this, "ReactSite", {
locally if I run
npm run test
everything passes. And if I cd into the
ReactSite
and run
npx craco build
it builds successfully
Light googling says, increase the amount of memory but erm… I don’t think that’s cocrect I guess
d
I was getting some of these Thursday on deploys. I increased the memory on CI/CD and it seems fine today and yesterday.
f
Not sure if it’s related, but these 2 packages seem to have the wrong version. Can you share your
package.json
?
d
Here is the package.json. Everything was working with deployment so I’ve been holding off on updating AWS until I was confident that I could troubleshoot anything that came up. I can update it today after work and see if that fixes it!.
Copy code
},
  "devDependencies": {
    "@aws-cdk/assert": "1.126.0"
  },
  "dependencies": {
    "@aws-cdk/core": "1.139.0",
    "@sendgrid/mail": "^7.6.0",
    "@serverless-stack/cli": "0.58.0",
    "@serverless-stack/resources": "0.58.0",
    "csvtojson": "^2.0.10",
    "stripe": "8.196.0",
    "twilio": "3.73.0"
  },
  "jest": {
    "testPathIgnorePatterns": [
      "frontend",
      "website"
    ]
  },
  "engines": {
    "node": "14.18.1"
  }
f
Yeah… just re-read ur msg and u mentioned the tests worked locally. Probably not version related. Have you tried bumping up the memory? Or commenting out the rest of the test and just run this one, just to ensure Jest isn’t running multiple builds concurrently?
d
I actually think it might be version related, @Frank, I had exactly zero of these until I upgraded to
0.60.2
, when I had it happen about 50% of the time. I think the version may just use more memory, for some reason, though.
d
Or commenting out the rest of the test and just run this one
Let me try this real quick. Its so straightforward and might help in case Derek’s intuition is correct. I didn’t try bumping up the memory. I did add
--run-in-band
to the test. I’m using seed for deployment and it wasn’t obvious how to increase memory
Big new error after commenting that out
Copy code
Synthesizing CDK
synth {
  output: '.build/cdk.out',
  app: 'node .build/run.js',
  rollback: undefined,
  roleArn: undefined,
  verbose: 2,
  noColor: true
}
CDK toolkit version: 2.7.0 (build cfb09d5)
Command line arguments: {
  _: [ 'synth' ],
  'version-reporting': false,
  versionReporting: false,
  app: 'node .build/run.js',
  a: 'node .build/run.js',
  output: '.build/cdk.out',
  o: '.build/cdk.out',
  quiet: true,
  q: true,
  color: false,
  verbose: 1,
  v: 1,
  disableVersionCheck: 'true',
  lookups: true,
  'ignore-errors': false,
  ignoreErrors: false,
  json: false,
  j: false,
  debug: false,
  ec2creds: undefined,
  i: undefined,
  'path-metadata': true,
  pathMetadata: true,
  'asset-metadata': true,
  assetMetadata: true,
  'role-arn': undefined,
  r: undefined,
  roleArn: undefined,
  staging: true,
  'no-color': false,
  noColor: false,
  validation: true,
  '$0': 'node_modules/@serverless-stack/core/node_modules/aws-cdk/bin/cdk'
}
cdk.context.json: {
  "hosted-zone:account=560195320067:domainName=<http://comicshelper.com:region=us-east-1|comicshelper.com:region=us-east-1>": {
    "Id": "/hostedzone/Z0463222O9C7UT88PZ86",
    "Name": "comicshelper.com."
  }
}
merged settings: {
  versionReporting: false,
  pathMetadata: true,
  output: '.build/cdk.out',
  app: 'node .build/run.js',
  context: {},
  debug: false,
  assetMetadata: true,
  toolkitBucket: {},
  staging: true,
  bundlingStacks: [ '*' ],
  lookups: true
}
Toolkit stack: CDKToolkit
Setting "CDK_DEFAULT_REGION" environment variable to us-east-1
Resolving default credentials
Looking up default account ID from STS
Default account ID: 560195320067
Setting "CDK_DEFAULT_ACCOUNT" environment variable to 560195320067
context: {
  'hosted-zone:account=560195320067:domainName=<http://comicshelper.com:region=us-east-1|comicshelper.com:region=us-east-1>': { Id: '/hostedzone/Z0463222O9C7UT88PZ86', Name: 'comicshelper.com.' },
  'aws:cdk:enable-path-metadata': true,
  'aws:cdk:enable-asset-metadata': true,
  'aws:cdk:disable-version-reporting': true,
  'aws:cdk:bundling-stacks': [ '*' ]
}
outdir: .build/cdk.out
env: {
  CDK_DEFAULT_REGION: 'us-east-1',
  CDK_DEFAULT_ACCOUNT: '560195320067',
  CDK_CONTEXT_JSON: '{"hosted-zone:account=560195320067:domainName=<http://comicshelper.com:region=us-east-1%22:{%22Id%22:%22/hostedzone/Z0463222O9C7UT88PZ86%22,%22Name%22:%22comicshelper.com.%22},%22aws:cdk:enable-path-metadata%22:true,%22aws:cdk:enable-asset-metadata%22:true,%22aws:cdk:disable-version-reporting%22:true,%22aws:cdk:bundling-stacks%22:[%22*%22]|comicshelper.com:region=us-east-1":{"Id":"/hostedzone/Z0463222O9C7UT88PZ86","Name":"comicshelper.com."},"aws:cdk:enable-path-metadata":true,"aws:cdk:enable-asset-metadata":true,"aws:cdk:disable-version-reporting":true,"aws:cdk:bundling-stacks":["*"]>}',
  CDK_OUTDIR: '.build/cdk.out',
  CDK_CLI_ASM_VERSION: '16.0.0',
  CDK_CLI_VERSION: '2.7.0'
}
[dotenv][DEBUG] did not match key and value when parsing line 1: # These variables are only available in your SST code.
[dotenv][DEBUG] did not match key and value when parsing line 2: # To apply them to your Lambda functions, checkout this doc - <https://docs.serverless-stack.com/environment-variables#environment-variables-in-lambda-functions>
[dotenv][DEBUG] did not match key and value when parsing line 3: 
[dotenv][DEBUG] did not match key and value when parsing line 5: 
Building static site frontend
> frontend@0.1.0 build /tmp/seed/source/frontend
> craco build
Creating an optimized production build...
Failed to compile.
Failed to minify the bundle. Error: static/js/3.b69fe06d.chunk.js from Terser
Error: Call retries were exceeded
    at /tmp/seed/source/frontend/node_modules/react-scripts/scripts/build.js:188:23
    at finalCallback (/tmp/seed/source/frontend/node_modules/webpack/lib/Compiler.js:257:39)
    at /tmp/seed/source/frontend/node_modules/webpack/lib/Compiler.js:273:13
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/seed/source/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at AsyncSeriesHook.lazyCompileHook (/tmp/seed/source/frontend/node_modules/tapable/lib/Hook.js:154:20)
    at onCompiled (/tmp/seed/source/frontend/node_modules/webpack/lib/Compiler.js:271:21)
    at /tmp/seed/source/frontend/node_modules/webpack/lib/Compiler.js:681:15
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/seed/source/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/tmp/seed/source/frontend/node_modules/tapable/lib/Hook.js:154:20)
    at /tmp/seed/source/frontend/node_modules/webpack/lib/Compiler.js:678:31
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/seed/source/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/tmp/seed/source/frontend/node_modules/tapable/lib/Hook.js:154:20)
    at /tmp/seed/source/frontend/node_modules/webpack/lib/Compilation.js:1423:35
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/tmp/seed/source/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/tmp/seed/source/frontend/node_modules/tapable/lib/Hook.js:154:20)
    at /tmp/seed/source/frontend/node_modules/webpack/lib/Compilation.js:1414:32
Read more here: <https://cra.link/failed-to-minify>
What if this has nothing to do with SST and everythign to do with me 😢
npm run build works locally as well
Copy code
Error: There was a problem building the "ReactSite" StaticSite.
    at ReactStaticSite.buildApp (/tmp/seed/source/node_modules/@serverless-stack/resources/src/StaticSite.ts:203:15)
    at new StaticSite (/tmp/seed/source/node_modules/@serverless-stack/resources/src/StaticSite.ts:95:24)
    at new ReactStaticSite (/tmp/seed/source/node_modules/@serverless-stack/resources/src/ReactStaticSite.ts:43:5)
    at new MyStack (/tmp/seed/source/stacks/MyStack.js:151:22)
    at Object.main (/tmp/seed/source/stacks/index.js:10:20)
    at Object.<anonymous> (/tmp/seed/source/.build/run.js:94:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
Error: Subprocess exited with error 1
    at ChildProcess.<anonymous> (/tmp/seed/source/node_modules/@serverless-stack/core/node_modules/aws-cdk/lib/api/cxapp/exec.ts:127:23)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:467:12)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
There was an error synthesizing your app.
ERROR: Error: Subprocess exited with error 1
Yeah… turns out it was my fault and I had a CSV in the root directory. deleting that makes it work