# Running KomoonRSSCrawler on cPanel / CloudLinux (shared hosting)

On shared hosting that uses **CloudLinux** and **LVE** (Lightweight Virtual Environment), the RSS crawler can fail at startup with:

```text
RangeError: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for new instance
    at lazyllhttp (node:internal/deps/undici/undici:5943:32)
```

This is due to **Virtual Memory (VMEM)**, not physical RAM. From Node.js 18 onward, the built-in HTTP stack (undici) uses WebAssembly (llhttp). When V8 initializes that WebAssembly module, it reserves a large block of **virtual address space** (often 4–10 GB) for guard regions. CloudLinux caps virtual memory per account, so the Node process hits that limit before the script does any real work.

## Fix: reduce VMEM usage

Set this environment variable so Node uses a smaller virtual memory footprint for WebAssembly:

```bash
NODE_OPTIONS="--disable-wasm-trap-handler"
```

### Manual run (SSH)

Activate the app’s Node virtualenv, then run the batch with the option:

```bash
source /home/bytescorp/nodevenv/rsscrawler.komoon.app/app/20/bin/activate
cd /home/bytescorp/rsscrawler.komoon.app/app

NODE_OPTIONS="--disable-wasm-trap-handler" CRAWL_COUNTRY=MX CRAWL_STATE=Zacatecas CRAWL_MUNICIPALITY=Jerez node src/runBatch.js
```

Or export it once per session:

```bash
export NODE_OPTIONS="--disable-wasm-trap-handler"
CRAWL_COUNTRY=MX CRAWL_STATE=Zacatecas CRAWL_MUNICIPALITY=Jerez node src/runBatch.js
```

### Cron

See **[cron-jobs-hosting.md](./cron-jobs-hosting.md)** for full copy-paste cron lines (state, municipalities, cleanup).

Include `NODE_OPTIONS` in crawl cron jobs. Use the **full** `nodevenv` binary path — not bare `node`.

### Alternative (if the above is not enough)

Some hosts suggest disabling the experimental fetch so Node falls back to the legacy HTTP agent and bypasses WebAssembly:

```bash
NODE_OPTIONS="--no-experimental-fetch" node src/runBatch.js
```

Try `--disable-wasm-trap-handler` first; use `--no-experimental-fetch` only if the crawler still fails and your host recommends it.

## cPanel Node.js app

| Setting | Value |
|---------|--------|
| Application root | `rsscrawler.komoon.app/app` |
| Application URL | `rsscrawler.komoon.app` / `app` |
| Node.js | 20.x |
| Startup file | `app.js` (if used for health/status; batch work runs via cron CLI) |

Public data URL: `https://rsscrawler.komoon.app/data` (e.g. `sync_manifest.json`).

## Reference

- The `--disable-wasm-trap-handler` flag is intended for restricted environments (e.g. cPanel/CloudLinux) where virtual memory is limited.
- Physical memory (PMEM) limits can be increased by the host; VMEM is usually capped per account for stability, so the flag is the right approach on shared hosting.
