adobe / adobe/aem-project-archetype

Adobe I/O SSR (React) action does not work

Open
#1,093 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
596
Forks
431
Avg merge
10d 6h
Merged PRs (30d)
1

Description

After creating a new AEM project, the SSR (React) build does not work on Adobe I/O after deployment via `npm run deploy-ssr-ioruntime`.

Locally the Adobe I/O SSR build also does not work unless a debugger is attached. I assume this is because code is proxied from the actual src folder and dependencies can be resolved properly in this case.

### Expected Behaviour

Activation for the SSR action on Adobe I/O is successful and returns the rendered HTML.

### Actual Behaviour

SSR Rendering does not work and following warning is shown in the error.log
```
22.06.2023 11:24:30.095 *WARN* [[0:0:0:0:0:0:0:1] [1687425868769] GET /content/wknd-spa-react/us/en/home.html HTTP/1.1] com.adobe.cq.remote.content.renderer.impl.servlet.RemoteContentRendererRequestHandlerServlet Remote error: code = 400 and message = {_ "code": "QueNTNEWFEurukDJiHCtb8DX3IcEUSxP",_ "error": "Response is not valid 'message/http'."_}
```

The activations on Adobe I/O show the following type of errors.
```
{
"result": {
"error": "Initialization has failed due to: Error: Cannot find module '/nodejsAction/TMmhc0Rf'\n at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)\n at Function.Module._load (internal/modules/cjs/loader.js:562:25)\n at Module.require (internal/modules/cjs/loader.js:692:17)\n at require (internal/modules/cjs/helpers.js:25:18)\n at eval (eval at (/nodejsAction/services/runner.js:76:49), :1:1)\n at /nodejsAction/services/runner.js:76:49"
},
"size": 506,
"status": "application error",
"success": false
}
```

### Reproduce Scenario (including but not limited to)

1. Create a new project via aem-project-archetype with frontendModule=react, enableSSR=y
2. Follow the [WKND SPA](https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/spa-editor/react/overview.html) (with SSR) Tutorial
3. Setup an Adobe I/O Project with various workspaces and configure AIO environment variables
4. Deploy application to AEM (via mvn) and Adobe I/O (via aio)
5. Trigger SSR by opening http://localhost:4502/content/wknd-spa-react/us/en/home.html?wcmmode=disabled

#### Platform and Version

AEM Archetype Version 42
macOS Ventura 13.4
Node v16.20.1
NPM 8.19.4

#### Logs taken while reproducing problem

After `npm run start-ssr-ioruntime` the dist folder has the following structure.

```
 dist
├──  app.js
├──  app.js.map
├──  application
│ └──  actions
│ ├──  ssr-temp -> ~/aem-guides-wknd-spa.react.ssr/ui.frontend/dist/application/actions/wknd-spa-react-0.1.0/ssr-temp
│ ├──  ssr.zip -> ~/aem-guides-wknd-spa.react.ssr/ui.frontend/dist/application/actions/wknd-spa-react-0.1.0/ssr.zip
│ └──  wknd-spa-react-0.1.0
│ ├──  ssr-temp
│ │ ├──  index.85e18686cff29326ff33.js
│ │ └──  index.js
│ │ └──  app
│ │ └──  app.js
│ └──  ssr.zip
└──  last-built-actions.json
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with `npm run start-ssr-ioruntime` and `npm run deploy-ssr-ioruntime`, then inspect the generated `dist/application/actions` contents and the Adobe I/O activation logs. Trace why the deployed SSR action cannot resolve its generated module; done means activation succeeds and returns rendered HTML through the AEM page request.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, react
Domain
build-system, cloud, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.