aws-amplify / aws-amplify/amplify-hosting

Nextjs SSR build fails with [ERROR]: BadRequest: null

Open
#2,788 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### App Id

djkkm4s5vy3oj

### Region

eu-west-2

### Amplify Hosting feature

Logging

### Describe the bug

Nextjs SSR build fails with the following error message below. Changes from previous build are additional pages being added. The build does work locally.

2022-06-02T22:26:48.095Z [INFO]: Starting SSR Build...
2022-06-02T22:59:38.948Z [ERROR]: BadRequest: null
at Request.extractError (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/services/s3.js:691:35)
at Request.callListeners (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at Request.emit (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at callNextListener (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
at IncomingMessage.onEnd (/root/.//node_modules/@sls-next/aws-s3/node_modules/aws-sdk/lib/event_listeners.js:335:13)
at IncomingMessage.emit (events.js:412:35)
at IncomingMessage.emit (domain.js:475:12)
at endReadableNT (internal/streams/readable.js:1334:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'BadRequest',
region: 'us-east-1',
time: 2022-06-02T22:59:38.683Z,
requestId: 'C8NBB17H0Y4S0Z8Z',
extendedRequestId: 'k1sqd+fZ4ebUCzl1JxgUBSB0HHIAGC934Iua5nj9HWRiT5nGnI9SQ8BnMKnWp4HfiULexkuKlBc=',
cfId: undefined,
statusCode: 400,
retryable: false,
retryDelay: 59.99598886102082
}

### Expected behavior

2022-06-03T08:35:31.829Z [INFO]: Starting SSR Build...
2022-06-03T09:00:57.808Z [INFO]: SSR Build Complete.
2022-06-03T09:00:59.202Z [INFO]: # Completed phase: build
## Completed Frontend Build
2022-06-03T09:00:59.220Z [INFO]: ## Build completed successfully
2022-06-03T09:00:59.225Z [INFO]: # Starting caching...

### Reproduction steps

Run pipeline or 'Redeploy this version' button on the UI

### Build Settings

```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
test:
artifacts:
baseDirectory: cypress
configFilePath: '**/mochawesome.json'
files:
- '**/*.png'
- '**/*.mp4'
phases:
preTest:
commands:
- npm ci
- npm install wait-on
- npm install pm2
- npm install mocha@5.2.0 mochawesome mochawesome-merge mochawesome-report-generator
- "npm start & npx wait-on http://localhost:8080"
test:
commands:
- 'npx cypress run --reporter mochawesome --reporter-options "reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss"'
postTest:
commands:
- npx mochawesome-merge cypress/report/mochawesome-report/mochawesome*.json > cypress/report/mochawesome.json
- npx pm2 kill
```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by running the documented npm run build locally, then reproduce the pipeline or “Redeploy this version” flow and inspect the SSR build logs around the AWS SDK S3 BadRequest. Compare the local and hosted environments, including the .next artifact configuration and build commands; done means the logs reach “SSR Build Complete” and the frontend build succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, nextjs
Domain
ci-cd, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.