Skip to content

Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.

fix(v0.16.1): self-hosted next build — keep Prisma out of the edge instrumentation bundle (#39)

Ashiq Hussain Mira93de97df503
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 59644a7..6b4bb59 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -34,7 +34,7 @@ jobs:
lint-unit:
name: lint-unit
runs-on: ubuntu-latest
- timeout-minutes: 10
+ timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -60,6 +60,16 @@ jobs:
- name: Unit tests
run: npm test
+ # v0.16.1: the gate never ran `next build` — A1's edge-
+ # instrumentation regression (Prisma traced into the edge bundle
+ # via a static import) passed typecheck, lint, unit AND the
+ # dev-server e2e, and only failed on the self-hosted deployer.
+ # The production build is part of what this gate protects.
+ # No DB needed: route handlers are request-time, the landing
+ # page is static, and PrismaClient construction is lazy.
+ - name: Production build
+ run: npm run build
+
# ── Browser suite: merges to main + manual dispatch ───────────────
e2e:
name: e2e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e6582e..35525a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,38 @@
All notable changes to Canvix will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
+## [0.16.1] — 2026-11-07
+
+### Fixed
+
+- **Self-hosted `next build` regression (A1 follow-up).** A1 wired the
+ traffic counters into `withLogging` with a static import of
+ `@/lib/admin/traffic` — the Prisma client — which broke the
+ observability module's stdlib-only contract (v0.12.5) and with it
+ every self-hosted production build: Next also compiles
+ `src/instrumentation.ts` for the edge runtime, Turbopack followed the
+ new import into Prisma's query-compiler wasm loader, and `next build`
+ failed with "The export default was not found in module
+ …query_compiler_bg.postgresql.raw.wasm" (first seen on the canvix.app
+ VPS, where the failed build also wiped `.next/standalone` under the
+ running process — every static asset 500'd until a successful
+ rebuild). The counter now loads lazily behind the documented
+ `NEXT_RUNTIME` define — the edge compilation context folds the guard
+ to `return` at build time, so Prisma is never traced into the edge
+ instrumentation bundle — while runtime behaviour on Node is unchanged
+ (fire-and-forget, error-swallowing, `CANVIX_TRAFFIC=0` opt-out).
+- **CI never ran `next build`.** The lint-unit gate type-checked,
+ linted and unit-tested, and the e2e suite boots `npm run dev` — so
+ the edge-instrumentation breakage passed every check and only failed
+ on a real deployer. lint-unit now runs the production build too
+ (timeout raised to fit).
+
+### Changed
+
+- `package-lock.json` version fields re-synced with `package.json`
+ (the 0.16.0 bump missed them, so every `npm install` on a deploy
+ VPS dirtied the lockfile).
+
## [0.16.0] — 2026-11-07
### Added
diff --git a/package-lock.json b/package-lock.json
index 9ddaab3..c448e63 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "canvix",
- "version": "0.15.2",
+ "version": "0.16.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "canvix",
- "version": "0.15.2",
+ "version": "0.16.1",
"hasInstallScript": true,
"dependencies": {
"@imgly/background-removal": "^1.7.0",
diff --git a/package.json b/package.json
index 1eb9c4d..7cf0a95 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "canvix",
- "version": "0.16.0",
+ "version": "0.16.1",
"private": false,
"description": "Canvix — free & open-source graphic design tool. A community-built Canva alternative.",
"scripts": {
diff --git a/src/lib/observability.ts b/src/lib/observability.ts
index 70e5889..54d2d96 100644
--- a/src/lib/observability.ts
+++ b/src/lib/observability.ts
@@ -21,7 +21,6 @@
// ─────────────────────────────────────────────────────────────
import type { NextRequest } from 'next/server'
-import { recordTraffic } from '@/lib/admin/traffic'
/** The app version answering requests — from package.json at build time. */
export const APP_VERSION = process.env.npm_package_version ?? 'unknown'
@@ -67,6 +66,34 @@ export function logApiRequest(entry: ApiRequestLog): void {
})
}
+// ── traffic counters (v0.16.1) ───────────────────────────────
+//
+// v0.16 (A1) wired the aggregate counters into withLogging via a
+// static `import { recordTraffic }` — which, through src/lib/db.ts,
+// is the Prisma client. That silently broke this module's v0.12.5
+// contract ("stdlib-only, runs on every runtime"): Next also compiles
+// src/instrumentation.ts for the EDGE runtime, Turbopack followed the
+// new static import into Prisma's query-compiler wasm loader, and
+// `next build` failed on the self-hosted deployer ("The export default
+// was not found in module …raw.wasm") — the failed build wiped
+// .next/standalone under the running process and took canvix.app's
+// static assets down with it.
+//
+// The fix restores the contract: this module stays stdlib-only, and
+// the counter loads lazily behind the documented NEXT_RUNTIME define.
+// In the edge compilation context NEXT_RUNTIME is replaced with
+// "edge" at build time, so the guard folds to `return` and Prisma is
+// never traced into the edge instrumentation bundle. On the Node
+// server (and in vitest, where NEXT_RUNTIME is unset) the import
+// resolves on first request — same fire-and-forget, error-swallowing
+// contract A1 defined.
+function countTraffic(name: string, method: string, status: number): void {
+ if (process.env.NEXT_RUNTIME === 'edge') return
+ void import('@/lib/admin/traffic')
+ .then((m) => m.recordTraffic(name, method, status))
+ .catch(() => {})
+}
+
/**
* Wrap an API route handler with opt-in request logging AND always-on
* aggregate traffic counters (v0.16 A1 — CANVIX_TRAFFIC=0 opts out;
@@ -82,7 +109,7 @@ export function withLogging<A extends unknown[]>(
): (req: NextRequest, ...args: A) => Promise<Response> {
return async (req, ...args) => {
// v0.16 (A1): aggregate traffic counters — independent of the stdout
- // switch above. Fire-and-forget by contract (recordTraffic swallows
+ // switch above. Fire-and-forget by contract (countTraffic swallows
// its own errors); counting must never delay or break the response
// it counts.
const start = now()
@@ -96,7 +123,7 @@ export function withLogging<A extends unknown[]>(
durationMs: now() - start,
})
}
- void recordTraffic(name, req.method, res.status)
+ countTraffic(name, req.method, res.status)
return res
} catch (error) {
if (requestLoggingEnabled()) {
@@ -107,7 +134,7 @@ export function withLogging<A extends unknown[]>(
durationMs: now() - start,
})
}
- void recordTraffic(name, req.method, 500)
+ countTraffic(name, req.method, 500)
throw error
}
}