aws-amplify / aws-amplify/amplify-hosting
while deploying my nextjs project with sentry on aws amplify build getting failed
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+) and [discussions](https://github.com/aws-amplify/amplify-js/discussions).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### JavaScript Framework
Next.js
### Amplify APIs
Not applicable
### Amplify Categories
Not applicable
### Environment information
```
# Put output below this line
```
### Describe the bug
```bash
I am using nextjs 11.1.3 when I added sentry error tracking to my next js project when i build and run it locally it works fine but when i deploy my sentry nextjs project on aws amplyfy my build getting failed with following error,
'> Build error occurred\n' +
'Error: spawn ENOMEM\n' +
' at ChildProcess.spawn (node:internal/child_process:420:11)\n' +
' at spawn (node:child_process:733:9)\n' +
' at fork (node:child_process:169:10)\n' +
' at ChildProcessWorker.initialize (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:141:45)\n' +
' at new ChildProcessWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:132:10)\n' +
' at WorkerPool.createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:44:12)\n' +
' at new BaseWorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/base/BaseWorkerPool.js:135:27)\n' +
' at new WorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:30:1)\n' +
' at new Worker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/index.js:167:26)\n' +
' at createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:15:28)\n' +
' at new Worker1 (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:21:9)\n' +
' at /codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:432:31\n' +
' at async Span.traceAsyncFn (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/telemetry/trace/trace.js:60:20)\n' +
' at async Object.build [as default] (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:77:25) {\n' +
' errno: -12,\n' +
" code: 'ENOMEM',\n" +
" syscall: 'spawn'\n" +
'}',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
[G
2023-08-10T16:47:33.927Z [ERROR]: [?25h[G[J
300s › darxjey0xrl5c › Error: Command failed with exit code 1: node_modules/.bin/next build
```
### To Reproduce
**Below is my aws amplify build logs**
'> Build error occurred\n' +
'Error: spawn ENOMEM\n' +
' at ChildProcess.spawn (node:internal/child_process:420:11)\n' +
' at spawn (node:child_process:733:9)\n' +
' at fork (node:child_process:169:10)\n' +
' at ChildProcessWorker.initialize (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:141:45)\n' +
' at new ChildProcessWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:132:10)\n' +
' at WorkerPool.createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:44:12)\n' +
' at new BaseWorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/base/BaseWorkerPool.js:135:27)\n' +
' at new WorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:30:1)\n' +
' at new Worker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/index.js:167:26)\n' +
' at createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:15:28)\n' +
' at new Worker1 (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:21:9)\n' +
' at /codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:432:31\n' +
' at async Span.traceAsyncFn (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/telemetry/trace/trace.js:60:20)\n' +
' at async Object.build [as default] (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:77:25) {\n' +
' errno: -12,\n' +
" code: 'ENOMEM',\n" +
" syscall: 'spawn'\n" +
'}',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
[G
2023-08-10T16:47:33.927Z [ERROR]: [?25h[G[J
300s › darxjey0xrl5c › Error: Command failed with exit code 1: node_modules/.bin/next build
### Expected behavior
my nextjs project which contains sentry error tracking build should not fail.
### Reproduction steps
after deploying my nextjs sentry project on aws amplify build getting failed.
### Code Snippet
```javascript
// Put your code below this line.
**next.config.js File**
```javascript
const { withSentryConfig } = require("@sentry/nextjs");
const nextConfig = {
...nextConfigurations
productionBrowserSourceMaps: true,
sentry:{
widenClientFileUpload: true,
transpileClientSDK: true,
hideSourceMaps: true,
disableLogger: true,
}
};
const sentryWebpackPluginOptions = {
org: process.env.NEXT_PUBLIC_SENTRY_ORG_NAME,
project: process.env.NEXT_PUBLIC_SENTRY_PROJECT_NAME,
authToken: process.env.NEXT_PUBLIC_SENTRY_AUTH_TOKEN,
sourceMapFilename: '[name].[hash].js.map',
silent: true,
};
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
```
**sentry.client.config.js**
```javascript
import * as Sentry from "@sentry/nextjs";
import { ContextLines } from "@sentry/integrations";
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampleRate: 0.2,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 0.1,
integrations: [
new Sentry.Replay(),
new ContextLines({
frameContextLines: 7,
}),
],
});
```
**app.js**
```javascript
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
integrations: [
new BrowserTracing()
],
tracesSampleRate: 0.2,
});
```
So this setup works well for me in locally when i build locally sourcemap getting uploaded to my sentry dashboard and also i get proper stack starce but when i try to deploy on aws amplify my build is failing and getting below error
```javascript
'> Build error occurred\n' +
'Error: spawn ENOMEM\n' +
' at ChildProcess.spawn (node:internal/child_process:420:11)\n' +
' at spawn (node:child_process:733:9)\n' +
' at fork (node:child_process:169:10)\n' +
' at ChildProcessWorker.initialize (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:141:45)\n' +
' at new ChildProcessWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:132:10)\n' +
' at WorkerPool.createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:44:12)\n' +
' at new BaseWorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/base/BaseWorkerPool.js:135:27)\n' +
' at new WorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:30:1)\n' +
' at new Worker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/index.js:167:26)\n' +
' at createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:15:28)\n' +
' at new Worker1 (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:21:9)\n' +
' at /codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:432:31\n' +
' at async Span.traceAsyncFn (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/telemetry/trace/trace.js:60:20)\n' +
' at async Object.build [as default] (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:77:25) {\n' +
' errno: -12,\n' +
" code: 'ENOMEM',\n" +
" syscall: 'spawn'\n" +
'}',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
[G
2023-08-10T16:47:33.927Z [ERROR]: [?25h[G[J
300s › darxjey0xrl5c › Error: Command failed with exit code 1: node_modules/.bin/next build
```
I am not getting why I am getting this problem only when i deploy it on aws amplify locally everything working fine.
```
### Log output
```
// Put your logs below this line
> Build error occurred
Error: spawn ENOMEM
at ChildProcess.spawn (node:internal/child_process:420:11)
at spawn (node:child_process:733:9)
at fork (node:child_process:169:10)
at ChildProcessWorker.initialize (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:141:45)
at new ChildProcessWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:132:10)
at WorkerPool.createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:44:12)
at new BaseWorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/base/BaseWorkerPool.js:135:27)
at new WorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:30:1)
at new Worker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/index.js:167:26)
at createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:15:28)
at new Worker1 (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:21:9)
at /codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:432:31
at async Span.traceAsyncFn (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/telemetry/trace/trace.js:60:20)
at async Object.build [as default] (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:77:25) {
errno: -12,
code: 'ENOMEM',
syscall: 'spawn'
}
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Checking validity of types...
info - Creating an optimized production build...
info - Using external babel configuration from /codebuild/output/src489982623/src/...-nextjs/.babelrc
info - Collecting page data...
at makeError (/root/.//node_modules/execa/lib/error.js:60:11)
at handlePromise (/root/.//node_modules/execa/index.js:118:26)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Builder.build (/root/.//node_modules/@sls-next/lambda-at-edge/dist/build.js:377:13)
at async NextjsComponent.build (/root/.//node_modules/@sls-next/-component/dist/component.js:165:13)
at async NextjsComponent.default (/root/.//node_modules/@sls-next/-component/dist/component.js:22:13)
at async fn (/root/.npm/_npx/780a6c1398234b48/node_modules/@/template/utils.js:280:41)
at async Promise.all (index 0)
at async executeGraph (/root/.npm/_npx/780a6c1398234b48/node_modules/@/template/utils.js:294:3)
at async Template.default (/root/.npm/_npx/780a6c1398234b48/node_modules/@/template/.js:67:38)
at async Object.runComponents (/root/.npm/_npx/780a6c1398234b48/node_modules/@/cli/src/index.js:222:17) {
shortMessage: 'Command failed with exit code 1: node_modules/.bin/next build',
command: 'node_modules/.bin/next build',
escapedCommand: '"node_modules/.bin/next" build',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: 'info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5\n' +
'info - Checking validity of types...\n' +
'info - Creating an optimized production build...\n' +
'info - Using external babel configuration from /codebuild/output/src489982623/src/...-nextjs/.babelrc\n' +
'info - Collecting page data...',
stderr: '\n' +
'warn - As of Tailwind CSS v2.2, `lightBlue` has been renamed to `sky`.\n' +
'warn - Update your configuration file to silence this warning.\n' +
'\n' +
'warn - As of Tailwind CSS v3.0, `warmGray` has been renamed to `stone`.\n' +
'warn - Update your configuration file to silence this warning.\n' +
'\n' +
'warn - As of Tailwind CSS v3.0, `trueGray` has been renamed to `neutral`.\n' +
'warn - Update your configuration file to silence this warning.\n' +
'\n' +
'warn - As of Tailwind CSS v3.0, `coolGray` has been renamed to `gray`.\n' +
'warn - Update your configuration file to silence this warning.\n' +
'\n' +
'warn - As of Tailwind CSS v3.0, `blueGray` has been renamed to `slate`.\n' +
'warn - Update your configuration file to silence this warning.\n' +
'(node:4289) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API\n' +
'(Use `node --trace-deprecation ...` to show where the warning was created)\n' +
'(node:4289) [DEP_WEBPACK_CHUNK_ADD_MODULE] DeprecationWarning: Chunk.addModule: Use new ChunkGraph API\n' +
'warn - Compiled with warnings\n' +
'\n' +
'./components/dashB/FooterDashboard.js\n' +
"Attempted import error: 'support_id' is not exported from '../../constants' (imported as 'support_id').\n" +
'\n' +
'./node_modules/typescript/lib/typescript.js\n' +
"Module not found: Can't resolve 'perf_hooks' in '/codebuild/output/src489982623/src/...-nextjs/node_modules/typescript/lib'\n" +
'\n' +
'./node_modules/typescript/lib/typescript.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/typescript/lib/typescript.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js\n' +
"Module not found: Can't resolve 'bufferutil' in '/codebuild/output/src489982623/src/...-nextjs/node_modules/engine.io-client/node_modules/ws/lib'\n" +
'\n' +
'./node_modules/engine.io-client/node_modules/ws/lib/validation.js\n' +
"Module not found: Can't resolve 'utf-8-validate' in '/codebuild/output/src489982623/src/...-nextjs/node_modules/engine.io-client/node_modules/ws/lib'\n" +
'\n' +
'./components/dashB/FooterDashboard.js\n' +
"Attempted import error: 'support_id' is not exported from '../../constants' (imported as 'support_id').\n" +
'\n' +
'./node_modules/next/dist/server/load-components.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/next/dist/server/load-components.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/next/dist/server/load-components.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/next/dist/server/require.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/next/dist/server/require.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/next/dist/server/require.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/typescript/lib/typescript.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'./node_modules/typescript/lib/typescript.js\n' +
'Critical dependency: the request of a dependency is an expression\n' +
'\n' +
'\n' +
'> Build error occurred\n' +
'Error: spawn ENOMEM\n' +
' at ChildProcess.spawn (node:internal/child_process:420:11)\n' +
' at spawn (node:child_process:733:9)\n' +
' at fork (node:child_process:169:10)\n' +
' at ChildProcessWorker.initialize (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:141:45)\n' +
' at new ChildProcessWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/workers/ChildProcessWorker.js:132:10)\n' +
' at WorkerPool.createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:44:12)\n' +
' at new BaseWorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/base/BaseWorkerPool.js:135:27)\n' +
' at new WorkerPool (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/WorkerPool.js:30:1)\n' +
' at new Worker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/node_modules/jest-worker/build/index.js:167:26)\n' +
' at createWorker (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:15:28)\n' +
' at new Worker1 (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/lib/worker.js:21:9)\n' +
' at /codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:432:31\n' +
' at async Span.traceAsyncFn (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/telemetry/trace/trace.js:60:20)\n' +
' at async Object.build [as default] (/codebuild/output/src489982623/src/...-nextjs/node_modules/next/dist/build/index.js:77:25) {\n' +
' errno: -12,\n' +
" code: 'ENOMEM',\n" +
" syscall: 'spawn'\n" +
'}',
```
### aws-exports.js
_No response_
### Manual configuration
_No response_
### Additional configuration
_No response_
### Mobile Device
_No response_
### Mobile Operating System
_No response_
### Mobile Browser
_No response_
### Mobile Browser Version
_No response_
### Additional information and screenshots
_No response_
Contributor guide
Research direction
Begin with the Amplify build log and the `next build` invocation, then compare them with the local build using the configuration shown in `next.config.js`, `sentry.client.config.js`, and `app.js`. Reproduce the failure in the Amplify environment and establish whether a successful deployment avoids the `spawn ENOMEM` error; the issue provides no environment output or confirmed fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, next.js
- Domain
- build-system, ci-cd, cloud, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100