@onlineapps/service-wrapper 2.0.50 → 2.0.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/service-wrapper",
3
- "version": "2.0.50",
3
+ "version": "2.0.52",
4
4
  "description": "Thin orchestration layer for microservices - delegates all infrastructure concerns to specialized connectors",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -11,7 +11,9 @@
11
11
  "test:coverage": "jest --coverage",
12
12
  "test:mocked": "node test/run-tests.js",
13
13
  "docs": "jsdoc2md --files src/**/*.js > API.md",
14
- "docs:html": "jsdoc -c jsdoc.json -d docs/html"
14
+ "docs:html": "jsdoc -c jsdoc.json -d docs/html",
15
+ "prepublishOnly": "cd $(git rev-parse --show-toplevel) && bash scripts/pre-publish-compatibility-check.sh shared/connector/service-wrapper",
16
+ "postpublish": "cd $(git rev-parse --show-toplevel) && bash scripts/update-manifest-from-npm.sh && bash scripts/update-all-services.sh"
15
17
  },
16
18
  "keywords": [
17
19
  "microservices",
@@ -33,7 +35,7 @@
33
35
  "@onlineapps/conn-orch-orchestrator": "^1.0.1",
34
36
  "@onlineapps/conn-orch-registry": "^1.1.25",
35
37
  "@onlineapps/conn-orch-validator": "^2.0.0",
36
- "@onlineapps/service-common": "^1.0.0",
38
+ "@onlineapps/service-common": "^1.0.4",
37
39
  "@onlineapps/monitoring-core": "^1.0.0"
38
40
  },
39
41
  "devDependencies": {
@@ -153,7 +153,8 @@ class ServiceWrapper {
153
153
  */
154
154
  async _waitForInfrastructureGate(context) {
155
155
  const { waitForInfrastructureReady } = require('@onlineapps/service-common');
156
- const redisUrl = this.config.wrapper?.cache?.url || process.env.REDIS_URL || 'redis://api_node_cache:6379';
156
+ const { requireEnv } = require('@onlineapps/service-common');
157
+ const redisUrl = this.config.wrapper?.cache?.url || requireEnv('REDIS_URL', 'Redis connection URL');
157
158
  const maxWait = parseInt(process.env.INFRASTRUCTURE_HEALTH_WAIT_MAX_TIME) || 300000;
158
159
  const checkInterval = parseInt(process.env.INFRASTRUCTURE_HEALTH_WAIT_CHECK_INTERVAL) || 5000;
159
160
 
@@ -562,6 +563,57 @@ class ServiceWrapper {
562
563
  }
563
564
  }
564
565
 
566
+ /**
567
+ * Run health check before workflow step (debug mode only)
568
+ * @private
569
+ * @param {Object} message - Workflow message
570
+ */
571
+ async _runHealthCheckBeforeWorkflowStep(message) {
572
+ if (!this.mqClient || !this.mqClient._transport) {
573
+ return;
574
+ }
575
+
576
+ const transport = this.mqClient._transport;
577
+
578
+ // Check if transport has performHealthCheck method (public API)
579
+ if (typeof transport.performHealthCheck === 'function') {
580
+ try {
581
+ const health = await transport.performHealthCheck();
582
+
583
+ this.logger?.debug('[ServiceWrapper] [DEBUG] Health check before workflow step', {
584
+ workflow_id: message.workflow_id || message.workflowId,
585
+ current_step: message.current_step,
586
+ health: {
587
+ healthy: health.healthy,
588
+ issues: health.issues,
589
+ consumers: {
590
+ active: health.consumers.active,
591
+ tracked: health.consumers.tracked
592
+ },
593
+ queues: {
594
+ checked: health.queues.checked,
595
+ missing: health.queues.missing,
596
+ noConsumer: health.queues.noConsumer
597
+ },
598
+ channels: health.channels
599
+ }
600
+ });
601
+
602
+ if (!health.healthy) {
603
+ this.logger?.warn('[ServiceWrapper] [DEBUG] Health check FAILED before workflow step', {
604
+ workflow_id: message.workflow_id || message.workflowId,
605
+ issues: health.issues
606
+ });
607
+ }
608
+ } catch (err) {
609
+ this.logger?.warn('[ServiceWrapper] [DEBUG] Health check error before workflow step', {
610
+ error: err.message,
611
+ workflow_id: message.workflow_id || message.workflowId
612
+ });
613
+ }
614
+ }
615
+ }
616
+
565
617
  /**
566
618
  * Register MQ channel close hooks and health monitoring
567
619
  * Must be called AFTER monitoring is initialized
@@ -637,9 +689,10 @@ class ServiceWrapper {
637
689
  const serviceName = this.config.service?.name || 'unnamed-service';
638
690
 
639
691
  // Health monitoring and channel close hooks configuration
692
+ // NOTE: Health monitoring is NOT run periodically - it's triggered manually before workflow steps in debug mode
640
693
  const healthCheckConfig = {
641
- healthCheckInterval: this.config.wrapper?.mq?.healthCheckInterval || 30000, // 30s
642
- healthCheckEnabled: this.config.wrapper?.mq?.healthCheckEnabled !== false, // Default: true
694
+ healthCheckInterval: this.config.wrapper?.mq?.healthCheckInterval || 30000, // Not used when healthCheckEnabled=false
695
+ healthCheckEnabled: false, // Disable periodic checks - we'll run manually before workflow steps
643
696
  criticalHealthShutdown: this.config.wrapper?.mq?.criticalHealthShutdown !== false, // Default: true
644
697
  criticalHealthShutdownDelay: this.config.wrapper?.mq?.criticalHealthShutdownDelay || 60000, // 60s
645
698
  // Health reporting callbacks
@@ -1197,6 +1250,11 @@ class ServiceWrapper {
1197
1250
  throw new Error('Workflow message must have current_step field or cookbook with at least one step');
1198
1251
  }
1199
1252
 
1253
+ // DEBUG MODE: Run health check before workflow step
1254
+ if (process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development') {
1255
+ await this._runHealthCheckBeforeWorkflowStep(message);
1256
+ }
1257
+
1200
1258
  // Normalize message format: Gateway sends workflowId, orchestrator expects workflow_id
1201
1259
  const normalizedMessage = {
1202
1260
  ...message,