tina4-nodejs 3.13.6 → 3.13.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -1,10 +1,10 @@
1
- # CLAUDE.md — AI Developer Guide for tina4-nodejs (v3.13.6)
1
+ # CLAUDE.md — AI Developer Guide for tina4-nodejs (v3.13.7)
2
2
 
3
3
  > This file helps AI assistants (Claude, Copilot, Cursor, etc.) understand and work on this codebase effectively.
4
4
 
5
5
  ## What This Project Is
6
6
 
7
- Tina4 for Node.js/TypeScript v3.13.6 — The Intelligent Native Application 4ramework. A convention-over-configuration structural paradigm. The developer writes TypeScript; Tina4 is invisible infrastructure.
7
+ Tina4 for Node.js/TypeScript v3.13.7 — The Intelligent Native Application 4ramework. A convention-over-configuration structural paradigm. The developer writes TypeScript; Tina4 is invisible infrastructure.
8
8
 
9
9
  The philosophy: zero ceremony, batteries included, file system as source of truth.
10
10
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- "version": "3.13.6",
6
+ "version": "3.13.7",
7
7
 
8
8
  "type": "module",
9
9
  "description": "Tina4 for Node.js/TypeScript \u2014 54 built-in features, zero dependencies",
@@ -1278,7 +1278,31 @@ ${reset}
1278
1278
  res({ error: "Not Found", statusCode: 404, message: `No route found for ${req.method} ${pathname}` }, 404);
1279
1279
  }
1280
1280
  } catch (err) {
1281
- console.error(" Error:", err);
1281
+ // v3.13.7: log structured + surface to observability BEFORE rendering.
1282
+ // Listeners get the canonical {exception, request} payload mirrored
1283
+ // by Python / PHP / Ruby. Listener errors are swallowed + warning-
1284
+ // logged so a broken listener can't break the 500 page.
1285
+ Log.error(`Route error: ${err instanceof Error ? `${err.name}: ${err.message}` : String(err)}`, {
1286
+ method: req?.method,
1287
+ path: req?.path,
1288
+ });
1289
+ try {
1290
+ const { Events } = await import("./events.js");
1291
+ Events.emit("tina4.request.error", { exception: err, request: req });
1292
+ } catch (listenerErr) {
1293
+ try {
1294
+ Log.warn(
1295
+ `Listener for tina4.request.error raised: ${
1296
+ listenerErr instanceof Error
1297
+ ? `${listenerErr.name}: ${listenerErr.message}`
1298
+ : String(listenerErr)
1299
+ }`
1300
+ );
1301
+ } catch {
1302
+ // Log failures must never block the 500 render.
1303
+ }
1304
+ }
1305
+
1282
1306
  if (!res.raw.writableEnded) {
1283
1307
  if (isDevMode() && err instanceof Error) {
1284
1308
  // Rich error overlay with stack trace, source context, and line numbers
@@ -1287,9 +1311,12 @@ ${reset}
1287
1311
  res.raw.writeHead(500, { "Content-Type": "text/html; charset=utf-8" });
1288
1312
  res.raw.end(overlayHtml);
1289
1313
  } else {
1290
- const errorMessage = !isTruthy(process.env.TINA4_DEBUG) ? "Internal Server Error" : String(err);
1314
+ // v3.13.7 SECURITY (CWE-209): production response body must NOT
1315
+ // contain the stack trace or exception message. Pass an empty
1316
+ // error_message — the 500.twig template only renders the trace
1317
+ // block when error_message is truthy.
1291
1318
  const html500 = await renderErrorPage(500, {
1292
- error_message: errorMessage,
1319
+ error_message: "",
1293
1320
  request_id: `${Date.now().toString(36)}`,
1294
1321
  path: req.path,
1295
1322
  }, templatesDir);
@@ -1297,7 +1324,7 @@ ${reset}
1297
1324
  res.raw.writeHead(500, { "Content-Type": "text/html; charset=utf-8" });
1298
1325
  res.raw.end(html500);
1299
1326
  } else {
1300
- res({ error: "Internal Server Error", statusCode: 500, message: errorMessage }, 500);
1327
+ res({ error: "Internal Server Error", statusCode: 500 }, 500);
1301
1328
  }
1302
1329
  }
1303
1330
  }
@@ -27,7 +27,7 @@ body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; c
27
27
  <div class="error-title">Server Error</div>
28
28
  </div>
29
29
  <div class="error-msg">Something went wrong while processing your request.</div>
30
- <pre class="error-trace">{{ error_message }}</pre>
30
+ {% if error_message %}<pre class="error-trace">{{ error_message }}</pre>{% endif %}
31
31
  <div class="error-footer">
32
32
  <span class="error-hint">Fix the error and save to auto-reload</span>
33
33
  <span class="error-id">{{ request_id }}</span>