@onlineapps/service-wrapper 2.0.46 → 2.0.48

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.46",
3
+ "version": "2.0.48",
4
4
  "description": "Thin orchestration layer for microservices - delegates all infrastructure concerns to specialized connectors",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1116,84 +1116,9 @@ class ServiceWrapper {
1116
1116
  throw new Error(`Unknown message format or operation: ${JSON.stringify(message)}`);
1117
1117
  }
1118
1118
 
1119
- // Send response to workflow.completed if workflow_id is present
1120
- if (message.workflow_id && this.mqClient) {
1121
- // Extract delivery configuration from context (passed from Gateway)
1122
- // Delivery can specify how to deliver the result (webhook, email, etc.)
1123
- const delivery = message.context?.delivery || null;
1124
-
1125
- const workflowResponse = {
1126
- workflow_id: message.workflow_id,
1127
- service: serviceName,
1128
- operation: message.step?.operation || message.operation,
1129
- status: 'completed',
1130
- output: result,
1131
- delivery: delivery, // Delivery configuration from Gateway context
1132
- flags,
1133
- timestamp: new Date().toISOString()
1134
- };
1135
-
1136
- try {
1137
- // Detailed logging before publish
1138
- const channelState = {
1139
- mqClientConnected: this.mqClient?._connected,
1140
- hasTransport: !!this.mqClient?._transport,
1141
- hasChannel: !!(this.mqClient?._transport?._channel),
1142
- channelClosed: this.mqClient?._transport?._channel?.closed,
1143
- hasConnection: !!(this.mqClient?._transport?._connection && !this.mqClient._transport._connection.closed)
1144
- };
1145
-
1146
- this.logger?.info(`[ServiceWrapper] [PUBLISH] Preparing to publish workflow.completed`, {
1147
- workflowId: message.workflow_id,
1148
- service: serviceName,
1149
- operation: workflowResponse.operation,
1150
- queue: 'workflow.completed',
1151
- ...channelState
1152
- });
1153
-
1154
- console.log(`[ServiceWrapper] [PUBLISH] Publishing workflow.completed for workflow ${message.workflow_id}`, channelState);
1155
-
1156
- await this.mqClient.publish('workflow.completed', workflowResponse);
1157
-
1158
- // Log success with details
1159
- this.logger?.info(`[ServiceWrapper] [PUBLISH] ✓ Workflow response sent to workflow.completed: ${message.workflow_id}`, {
1160
- workflowId: message.workflow_id,
1161
- queue: 'workflow.completed',
1162
- responseSize: JSON.stringify(workflowResponse).length
1163
- });
1164
- console.log(`[ServiceWrapper] [PUBLISH] ✓ Successfully published workflow.completed for ${message.workflow_id}`);
1165
- } catch (error) {
1166
- // Use error handler to log and handle the error
1167
- const errorContext = {
1168
- workflowId: message.workflow_id,
1169
- queue: 'workflow.completed',
1170
- error: error.message,
1171
- errorStack: error.stack,
1172
- mqClientConnected: this.mqClient?._connected,
1173
- hasTransport: !!this.mqClient?._transport,
1174
- hasChannel: !!(this.mqClient?._transport?._channel),
1175
- channelClosed: this.mqClient?._transport?._channel?.closed,
1176
- hasConnection: !!(this.mqClient?._transport?._connection && !this.mqClient._transport._connection.closed)
1177
- };
1178
-
1179
- this.logger?.error(`[ServiceWrapper] [PUBLISH] ✗ Failed to publish workflow.completed`, errorContext);
1180
- console.error(`[ServiceWrapper] [PUBLISH] ✗ Failed to publish workflow.completed for ${message.workflow_id}:`, error.message);
1181
- console.error(`[ServiceWrapper] [PUBLISH] Channel state:`, {
1182
- hasChannel: errorContext.hasChannel,
1183
- channelClosed: errorContext.channelClosed,
1184
- hasConnection: errorContext.hasConnection
1185
- });
1186
-
1187
- if (this.errorHandler) {
1188
- await this.errorHandler.logError({
1189
- moduleName: 'ServiceWrapper',
1190
- operation: 'sendWorkflowResponse',
1191
- error: error,
1192
- context: { workflowId: message.workflow_id, queue: 'workflow.completed' }
1193
- });
1194
- }
1195
- }
1196
- }
1119
+ // NOTE: workflow.completed is published by WorkflowOrchestrator._completeWorkflow()
1120
+ // ServiceWrapper should NOT publish here to avoid duplicate messages
1121
+ // If orchestrator is not used, ServiceWrapper would publish, but that's legacy path
1197
1122
 
1198
1123
  return result;
1199
1124