LifeMate — Personal, Family & Learning Companion

feat/child-device-safety
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
js 25 lines 1.03 KB
Raw
1 import express from 'express';
2 import { operationalErrorHandler, requestContext } from '../../src/operations.js';
3
4 // Exercise the actual error middleware over HTTP after response headers are sent.
5 const app = express();
6 app.use(requestContext);
7 let failStream;
8 let streamRequestId;
9 app.get('/partial-error', (req, res, next) => {
10 streamRequestId = req.requestId;
11 failStream = () => next(new Error(process.env.STREAM_ERROR_MARKER));
12 res.setHeader('Content-Type', 'text/plain');
13 res.write('started');
14 });
15 app.post('/trigger-error', (_req, res) => {
16 res.status(204).end();
17 failStream();
18 // Express schedules fallback error logging during next(err). This later
19 // callback lets the client wait for that logging opportunity before shutdown.
20 setImmediate(() => console.error(JSON.stringify({ type: 'stream_error_drained', requestId: streamRequestId })));
21 });
22 app.use(operationalErrorHandler);
23 const server = app.listen(0, '127.0.0.1', () => {
24 console.log(JSON.stringify({ type: 'stream_fixture_ready', port: server.address().port }));
25 });