Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ecosystem.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ module.exports = {
COMPUTE_MODE: 'local',
ALWAYS_ON: 'true'
}
},
// === CONTINUOUS BUILDING ===
{
name: 'project-genie',
script: './scripts/genesis.cjs',
autorestart: true,
watch: false,
max_memory_restart: '300M',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Setting max_memory_restart to '300M' is highly restrictive for a continuous build process. Build tools (such as webpack, vite, or typescript compilers) often require significant memory during compilation and can easily exceed 300MB. If PM2 restarts the process mid-build due to exceeding this limit, it can result in corrupted builds or infinite restart loops. Consider increasing this limit to at least '1G' to allow the build process sufficient headroom.

      max_memory_restart: '1G',

restart_delay: 5000,
env: {
GENESIS_LOOP: 'true',
FORCE_MUTATION: 'true',
ALWAYS_ON: 'true'
}
}
]
};
12 changes: 9 additions & 3 deletions workers/index.js → workers/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@
// ─── JWT Validation (native Web Crypto) ──────────────────────────────────────

function base64UrlDecode(str) {
str = str.replace(/-/g, '+').replace(/_/g, '/');
while (str.length % 4) str += '=';
return Uint8Array.from(atob(str), c => c.charCodeAt(0));
const b64 = str.replaceAll('-', '+').replaceAll('_', '/');
const padded = b64.padEnd(b64.length + (4 - (b64.length % 4)) % 4, '=');
const bin = atob(padded);
const len = bin.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = bin.charCodeAt(i);

Check warning on line 114 in workers/index.mjs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `String#codePointAt()` over `String#charCodeAt()`.

See more on https://sonarcloud.io/project/issues?id=Genesis-Conductor-Engine_Yennefer&issues=AZ9A08rz57DQ02g6Gf04&open=AZ9A08rz57DQ02g6Gf04&pullRequest=130
}
return bytes;
}

async function validateJWT(request) {
Expand Down
20 changes: 4 additions & 16 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
name = "yennefer"
main = "workers/index.js"
compatibility_date = "2024-09-23"
main = "workers/index.mjs"
compatibility_date = "2024-04-01"
compatibility_flags = ["nodejs_compat"]

# ─── Build step ──────────────────────────────────────────────────────────────
# Runs before `wrangler deploy` so frontend/build exists when assets are uploaded.
[build]
# Installs frontend deps and builds the SPA so frontend/build exists before
# `wrangler deploy` uploads assets. NODE_OPTIONS is required for
# react-scripts 5.x + Node 18+ (webpack 4 OpenSSL 3.0 compatibility).
command = "cd frontend && npm install --include=dev && GENERATE_SOURCEMAP=false CI=false NODE_OPTIONS=--openssl-legacy-provider npm run build"
command = "cd yennefer-observatory && npm install --legacy-peer-deps && npm run build"

# ─── Static Assets (React SPA build output) ──────────────────────────────────
# Built by `npm run build` (root package.json) before every `wrangler deploy`.
# Cloudflare Workers Builds CI runs that script automatically if present.
# The ASSETS binding serves the React bundle with proper cache headers and
# falls back to index.html for client-side routing.
[assets]
directory = "frontend/build"
directory = "yennefer-observatory/dist"
binding = "ASSETS"

# ─── Placement ───────────────────────────────────────────────────────────────
[placement]
mode = "smart"

# ─── Production environment (yennefer.quest) ─────────────────────────────────
# BACKEND_URL is set as a Cloudflare Worker secret (not a plain var) so it
# stays encrypted and is never committed to source:
Expand Down
Loading