nestjs-sqs icon indicating copy to clipboard operation
nestjs-sqs copied to clipboard

Type Error Cannot read properties of undefined (reading 'meta')

Open manojpawarsj12 opened this issue 2 years ago • 8 comments

the undefined issue in this library node : v16.19.0 Version: "@ssut/nestjs-sqs": "^2.0.0", OS: Windows 11 aws-sdk version: "2.1388.0"

    "errorMessage": "Cannot read properties of undefined (reading 'meta')",
    "errorType": "TypeError",
    "stackTrace": [
        "TypeError: Cannot read properties of undefined (reading 'meta')",
        "    at node_modules\\@ssut\\nestjs-sqs\\dist\\sqs.service.js:64:49",
        "    at Array.forEach (<anonymous>)",
        "    at SqsService.<anonymous> (\\node_modules\\@ssut\\nestjs-sqs\\dist\\sqs.service.js:55:83)",
        "    at Generator.next (<anonymous>)",
        "    at fulfilled (\\node_modules\\@ssut\\nestjs-sqs\\dist\\sqs.service.js:17:58)",
        "    at processTicksAndRejections (node:internal/process/task_queues:96:5)"
    ]
}

manojpawarsj12 avatar Jun 02 '23 22:06 manojpawarsj12

I'm also facing the same issue it's still working in my project with previous files but after removing the node_modules when I install it gives me this error

ziasultan2 avatar Jun 04 '23 05:06 ziasultan2

I had the same issue here. My issue was that my consumer (class with @SqsMessageHandler) was not defined/registered in the module 😢 I hope it helps others.

adamatti avatar Jun 22 '23 20:06 adamatti

I had the same issue here. My issue was that my consumer (class with @SqsMessageHandler) was not defined/registered in the module 😢 I hope it helps others.

Thanks man. It works. maybe the dude forgot to catch exception.

tombroskipc avatar Jul 16 '23 08:07 tombroskipc

Had this issue today too. After some debugging, found the root cause of the issue is if you pass a queue configuration to the module when there's no handler configured, it will error out, because of a missing return in this guard condition: https://github.com/ssut/nestjs-sqs/blob/master/lib/sqs.service.ts#L39

workmad3 avatar Aug 24 '23 10:08 workmad3

it is because your @SqsMessageHandler('QUEUE_NAME', true) is not registered

SK-CSE avatar Dec 06 '23 12:12 SK-CSE

also when i want to pass an env var to the SqsMessageHandler method decorator, when i pass the hardcoded queue name, everything is fine, but process.env.QUEUE_NAME won't work, don't sure why though

toufikat avatar Dec 12 '23 17:12 toufikat

@toufikat it is because how SqsMessageHandler method decorator work, please refer to my solution if you want dynamic queue name in decorator https://github.com/ssut/nestjs-sqs/issues/8#issuecomment-1842631842

SK-CSE avatar Dec 15 '23 08:12 SK-CSE

make sure that you user dotenv.config() in the file where you are using process.env.QUEUE_NAME had the same issue, on the local machine it worked without dotenv.config(), but on the server it doesn't

Fsociety-sem avatar Jan 03 '24 09:01 Fsociety-sem