aws-amplify / aws-amplify/amplify-hosting

CSR App build breaking with "Serverless Error"

Open
#3,570 5 comments 0 reactions 1 assignee Claimed by @Jay2113 View on GitHub
frontend-builds investigating usability
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.
- [X] I have removed any sensitive information from my code snippets and submission.

### App Id

d2ymg159vgfgla

### AWS Region

us-west-1

### Amplify Hosting feature

Monorepo

### Frontend framework

React

### Next.js version

N/A

### Next.js router

N/A

### Describe the bug

I have a mono-repo, using NX and pnpm as my package manager. While one of my applications is a nextjs app, the one I want to deploy is a normal, client side rendered (no SSR) React application.

My Amplify build successfully completes with the following message:
```
2023-07-04T19:03:41.718Z [INFO]:
> NX Successfully ran target build for project [redacted] and 19 tasks it depends on
Nx read the output from the cache instead of running the command for 18 out of 20 tasks.
2023-07-04T19:03:41.821Z [INFO]: View logs and investigate cache misses at [redacted]
```

But then it does this:
```
2023-07-04T19:03:41.843Z [INFO]: Starting SSR Build...
2023-07-04T19:04:22.702Z [ERROR]: Serverless Error ----------------------------------------
```

I noticed that my platform is set to "Web dynamic" and my framework is set to "NextJS - SSR" and I've tried changing that via:

```
aws amplify update-app --app-id d2ymg159vgfgla --platform WEB --region us-west-1
```
and:
```
aws amplify update-branch --app-id d2ymg159vgfgla --branch-name main --framework 'none' --region us-west-1
```

and while I see it updated on my general settings page, it goes back to Web dynamic - NextJS - SSR every time I trigger a new build.

### Expected behavior

I would expect to use the generated static js files to host my client side rendered app, instead of trying to start up a server. AS a result I would expect my build to pass.

### Reproduction steps

1. trigger build
2. notice build breaks

### Build Settings

```yaml
version: 1
applications:
- frontend:
phases:
build:
commands:
- cd ../../
- corepack enable
- corepack prepare pnpm@latest --activate
- pnpm install
- cd apps/backend-app
- amplify pull --appId $C8_BACKEND_APP_ID --envName $C8_BACKEND_ENV -y
- cd ../../
- NODE_ENV=production npx nx build frontend-app --configuration=production
artifacts:
baseDirectory: ../../dist/apps/frontend-app
files:
- '**/*'
cache:
paths:
- node_modules/**/*
appRoot: apps/frontend-app
```

### Log output

```
# Put your logs below this line
2023-07-04T19:03:41.843Z [INFO]: Starting SSR Build...
2023-07-04T19:04:22.702Z [ERROR]: Serverless Error ----------------------------------------
```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.