I have a service using Nestjs and when i set up an SQS consumer, using '@ssut/nestjs-sqs', it fails

609 Views Asked by At

I have a service using Nestjs and when i set up an SQS consumer, using '@ssut/nestjs-sqs'. Locally, it works perfect but when i try to deploy with gitlab CI/CD, there is an error log with the following message:

[Nest] 1  - 10/05/2023, 12:25:13 PM    WARN [SqsService] No metadata found for: 


/usr/src/app/node_modules/@ssut/nestjs-sqs/dist/sqs.service.js:64
                const isBatchHandler = metadata.meta.batch === true;
TypeError: Cannot read properties of undefined (reading 'meta')
    at /usr/src/app/node_modules/@ssut/nestjs-sqs/dist/sqs.service.js:64:49
    at Array.forEach (<anonymous>)
    at SqsService.<anonymous> (/usr/src/app/node_modules/@ssut/nestjs-sqs/dist/sqs.service.js:55:83)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/src/app/node_modules/@ssut/nestjs-sqs/dist/sqs.service.js:17:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)`

I'm using the consumer as following:

import { Injectable } from '@nestjs/common';
import { SqsConsumerEventHandler, SqsMessageHandler } from '@ssut/nestjs-sqs';
import * as AWS from 'aws-sdk';

@Injectable()
export class SQSService {
  constructor() {}
  @SqsMessageHandler('my_sqs_name', true)
  handleMessage(message: AWS.SQS.Message) {
    if (message[0].Body) {
      const body = JSON.parse(message[0].Body);

      const { issueId, salesChannel, date, issueName, user } = body[0];
      console.log({ message });

      console.log(`Mensaje de issue "${issueName}" recibido con éxito`);
    } else {
      console.log('No hay mensaje');
    }
    // Here i will consume data //
  }
  @SqsConsumerEventHandler('my_sqs_name', 'processing_error')
  public onProcessingError(error: Error, message: AWS.SQS.Message) {
    console.log(error, message);
  }
}

I try to deploy on gitlab CI/CD with all the environments variables setted up.

What's wrong??

0

There are 0 best solutions below