Aws Sqs Lambda "Cannot Read Property 'foreach'

Say howdy to AWS re:Post

If you are an active AWS Forums user, your profile has been migrated to re:Mail. Y'all can sign in to re:Post using your AWS credentials, consummate your re:Mail service contour, and verify your email to start request and answering questions.
If you are not an agile correspondent on AWS Forums, visit re:Mail service, sign in using your AWS credentials, and create a contour.
AWS Forums volition be available in read-but fashion until March 31st, 2022. On April 1st, 2022 AWS Forums will redirect to AWS re:Mail
FAQs
What happens to my posts on AWS Forums?
The most-viewed question-and-answer threads from AWS Forums have been migrated to re:Post. Nosotros plan to migrate more AWS Forums posts in the coming months.
What happens to my reputation points on Forums?
To retain your historical contributions to the AWS customs, we have migrated your reputation points to re:Post.

Discussion Forums

Discussion Forums > Category: Programmer Tools > Forum: AWS X-Ray > Thread: Trace SQS receiveMessages fails with empty queue.

Advanced search options
Trace SQS receiveMessages fails with empty queue.

Posted past: gertjvr

Posted on: Apr 29, 2022 1:54 AM

This question is answered.

When the sqs queue is empty ther response json object doesn't contain a Messages attribute, and the sdk assume it will ever be at that place.

I have posted a fix and is using an altered version of this in my current sample project and it working.
Fixed captureDescriptors role to return 0 if Messages attribute doesn't be.

                                            part captureDescriptors(descriptors, params)                                              {                                              var data =                                              {                                              };   _.each(descriptors, function(attributes, paramName)                                              {                                              var paramData;                                                                                              if                                                                                            (attributes.list && attributes.get_count)       paramData = params[paramName] ? params[paramName].length : 0;                                                                                              else                                                                                            paramData = attributes.get_keys ===                                                                                              true                                                                                            ? _.keys(params[paramName]) : params[paramName];                                                                                              if                                              (typeof attributes.rename_to === 'string')                                              {                                                                                              this                                              [attributes.rename_to] = paramData;                                              }                                                                                              else                                                                                            {                                              var formatted = toSnakeCase(paramName);                                                                                              this                                              [formatted] = paramData;                                              }                                              }, data);                                                                                              return                                                                                            data;                                              }                                                                                      

https://gist.github.com/gertjvr/ce22e8482db7fb85162f7767b33b7233#file-call_capturer-js-L74

Edited past: gertjvr on Apr 29, 2022 1:54 AM

Permlink Replies: 8 | Pages: 1 - Concluding Postal service: Jul 5, 2022 ten:36 AM by: Sandra@AWS

Replies

Re: Trace SQS receiveMessages fails with empty queue.

Posted past: Sandra@AWS

Posted on: May 1, 2022 12:01 PM

in response to: gertjvr in response to: gertjvr

How-do-you-do,

This prepare has been added and volition be available in the next release. Thank you for your contribution. We are continuing to iterate on community feedback and are striving to make 10-Ray integration a easy experience. Bug reports and fixes are much appreciated and we look frontward to working with the community to identify and resolve these problems.

Thank you,
Sandra

Re: Trace SQS receiveMessages fails with empty queue.

Posted past: geoff1111

Posted on: May 2, 2022 3:18 AM

in response to: Sandra@AWS in response to: Sandra@AWS

Encountered the same result. Here'south the stack trace:

                                              TypeError: Cannot read belongings 'length' of undefined     at Object.<anonymous> (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js:75:36)     at /var/chore/_optimize/fn/node_modules/aws-xray-sdk/node_modules/underscore/underscore.js:73:21     at Function._.each._.forEach (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/underscore/underscore.js:158:9)     at captureDescriptors (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js:71:five)     at Object.<bearding> (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js:45:22)     at /var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/underscore/underscore.js:73:21     at Function._.each._.forEach (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/underscore/underscore.js:158:9)     at CallCapturer.capture (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js:41:5)     at Aws.init (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/aws-xray-sdk-core/lib/segments/attributes/aws.js:27:25)     at                                                                                                  new                                                                                                Aws (/var/task/_optimize/fn/node_modules/aws-xray-sdk/node_modules/aws-xray-sdk-core/lib/segments/attributes/aws.js:17:eight)                                                                                          

gertjvr's patch above fixes the issue.

Re: Trace SQS receiveMessages fails with empty queue.

Posted by: gertjvr

Posted on: May eight, 2022 4:11 AM

in response to: Sandra@AWS in response to: Sandra@AWS

Any update, when nosotros tin can see another release that will include this ready?

Re: Trace SQS receiveMessages fails with empty queue.

Posted by: geoff1111

Posted on: May 18, 2022 2:40 AM

in response to: gertjvr in response to: gertjvr

Looks similar v1.1.ane has gone live with the fix: https://www.npmjs.com/package/aws-xray-sdk

Re: Trace SQS receiveMessages fails with empty queue.

Posted by: PPaskaris

Posted on: Jun 13, 2022 12:31 PM

in response to: Sandra@AWS in response to: Sandra@AWS

I'm encountering a similar event in roughly the same place. This is on v1.1.i with the fix for OP's issue.

                                              TypeError: Cannot read property 'Letters' of                                                                                                  null                                                                                                at Object.<bearding> (/var/task/node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js:75:22) at /var/chore/node_modules/underscore/underscore.js:73:21 at Function._.each._.forEach (/var/task/node_modules/underscore/underscore.js:158:9) at captureDescriptors (/var/task/node_modules/aws-xray-sdk-cadre/lib/patchers/call_capturer.js:74:5) at Object.<bearding> (/var/task/node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js:46:22) at /var/task/node_modules/underscore/underscore.js:73:21 at Part._.each._.forEach (/var/task/node_modules/underscore/underscore.js:158:9) at CallCapturer.capture (/var/chore/node_modules/aws-xray-sdk-cadre/lib/patchers/call_capturer.js:42:5) at Aws.init (/var/task/node_modules/aws-xray-sdk-core/lib/segments/attributes/aws.js:30:25) at                                                                                                  new                                                                                                Aws (/var/task/node_modules/aws-xray-sdk-core/lib/segments/attributes/aws.js:17:viii) at Asking.<anonymous> (/var/task/node_modules/aws-xray-sdk-core/lib/patchers/aws_p.js:86:36) at Asking.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20) at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:678:fourteen) at Request.transition (/var/runtime/node_modules/aws-sdk/lib/asking.js:22:10) at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:fourteen:12)                                                                                          
Re: Trace SQS receiveMessages fails with empty queue.

Posted by: Sandra@AWS

Posted on: Jun 13, 2022 5:23 PM

in response to: PPaskaris in response to: PPaskaris

Hi PPaskaris,

Information technology looks like part of the AWS SDKs APIs that the response.data object is "ready to null if a request fault occurs". I practise not believe we've encountered this issue before just due to mere gamble with the default AWS whitelist data listed for virtually APIs exercise not list response_descriptors. There is not a validation check on request.data when an error occurs.

Affected APIs from the default whitelist are:
dynamodb.listTables
sqs.listQueues
sqs.receiveMessage
sqs.sendMessageBatch

I have a fix already in for the adjacent release. I apologize for the inconvenience and thank you lot for reporting the event.

Cheers,
Sandra

Re: Trace SQS receiveMessages fails with empty queue.

Posted by: PPaskaris

Posted on: Jun 21, 2022 10:29 AM

in response to: Sandra@AWS in response to: Sandra@AWS

Do you know when nosotros tin can expect the next release to be published?

Re: Trace SQS receiveMessages fails with empty queue.

Posted past: Sandra@AWS

Posted on: Jul 5, 2022 10:36 AM

in response to: PPaskaris in response to: PPaskaris

Hi PPaskaris,

The new version (ane.i.two) is out now. Let u.s.a. know if you see whatsoever further issues.

Thanks,
Sandra

View Thread RSS Feed View Thread RSS Feeds

Icon Legend

Answered question
Unanswered question with answer points nevertheless bachelor
Unanswered question

AWS Forums Status Icons

Ace: 2000+ pts
Practiced: 750-1999 pts
Guide: 300-749 pts
Enthusiast: fifty-299 pts
Newbie: 5-49 pts
Amazonian

delaneyallin1942.blogspot.com

Source: https://forums.aws.amazon.com/thread.jspa?threadID=254767

0 Response to "Aws Sqs Lambda "Cannot Read Property 'foreach'"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel