I'm getting the following error when using release v2.36.0
TypeError: Cannot read property 'push' of undefined
at Request.HTTP_DATA (/user_code/node_modules/aws-sdk/lib/event_listeners.js:321:34)
at Request.callListeners (/user_code/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/user_code/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/user_code/node_modules/aws-sdk/lib/request.js:673:14)
at IncomingMessage.onReadable (/user_code/node_modules/aws-sdk/lib/event_listeners.js:231:32)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at emitReadable_ (_stream_readable.js:432:10)
at emitReadable (_stream_readable.js:426:7)
at readableAddChunk (_stream_readable.js:187:13)
I'm making requests that look something like the following on an interval.
new AWS.CloudFormation().describeStacks({
StackName: stackName
}, function(err, data) {
if (err) {
console.log("error describing stack " + stackName);
console.log(err)
return;
}
});
Theres errors appear to be pretty sporadic so Im not sure if they are considered normal errors or not.
There error appears to stem from a buffers array being undefined while handling an HTTP_DATA event. The reference to the array appears to get defined in another call to add for HTTP_HEADERS here.
It looks like the HTTP_DATA event listener assumes the HTTP_HEADERS event will have been dispatched first, which seems like it should be a safe assumption. It also assumes that HTTP_DONE has not yet been dispatched, which concats the collected data buffers and then deletes the buffers array (and again seems like it should be a safe assumption).
Which version of node are you using?
thanks for replying @jeskew. I'm running using this in a google cloud function, which according to their docs should be
The Cloud Functions Node.js execution environment follows the Node "LTS" releases, starting with the v6 LTS release published on 2016-10-18. The current Node.js version running in Cloud Functions is Node v6.9.1.
I am having major issues with this in Lambda querying DynamoDB using a Promise. Not sure if it is helpful to you.
2017-05-24T11:22:24.876Z 430188ef-4073-11e7-b337-efeb74a7aea9 { TypeError: Cannot read property 'push' of undefined
at Request.HTTP_DATA (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:321:34)
at Request.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:673:14)
at IncomingMessage.onReadable (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:231:32)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at emitReadable_ (_stream_readable.js:432:10)
at emitReadable (_stream_readable.js:426:7)
at readableAddChunk (_stream_readable.js:187:13)
message: 'Cannot read property \'push\' of undefined',
code: 'TypeError',
time: 2017-05-24T11:22:24.876Z,
statusCode: 200,
retryable: false,
retryDelay: 87.05819427380794 }
2017-05-24T11:22:24.877Z 430188ef-4073-11e7-b337-efeb74a7aea9 Unable to query the table. Error JSON: {
"message": "Cannot read property 'push' of undefined",
"code": "TypeError",
"time": "2017-05-24T11:22:24.876Z",
"statusCode": 200,
"retryable": false,
"retryDelay": 87.05819427380794
}
2017-05-24T11:22:24.894Z 430188ef-4073-11e7-b337-efeb74a7aea9 (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'push' of undefined
2017-05-24T11:22:24.895Z 430188ef-4073-11e7-b337-efeb74a7aea9 { TypeError: Cannot read property 'push' of undefined
at Request.HTTP_DATA (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:321:34)
at Request.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:673:14)
at IncomingMessage.onReadable (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:231:32)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at emitReadable_ (_stream_readable.js:432:10)
at emitReadable (_stream_readable.js:426:7)
at readableAddChunk (_stream_readable.js:187:13)
message: 'Cannot read property \'push\' of undefined',
code: 'TypeError',
time: 2017-05-24T11:22:24.876Z,
statusCode: 200,
retryable: false,
retryDelay: 87.05819427380794 }
@villagebike Are you using the version of the SDK provided by Lambda or bundling your own? If the latter is the case, the issue should be addressed in versions 2.50.0 and later.
I have exactly the same as @villagebike - I'm using AWS SDK 2.67.0 and I get this issue when using a dynamodb query as a promise. If I revert it back to a non-promise call then the function operates as per expected. I have the issue both locally and running under AWS Lambda (node 6.11.0 locally and 6.3 on Lambda)
Similar issue, on listObjectsV2, the .promise() call sometimes wouldn't return at all, hanging completely. The errors seemed to not be reported to the reject/catch handler. I've converted my code to manually create a promise and use the callback function parameter for this method. If I try to pass a callback function, and call .promise() I see this error. Since removing .promise() I haven't had any issues other than lengthy code.
I am having similar issue with v2.190.0 on node v8.9.1. The promise API keep failing and change to callback API fixes the issue
I hit this error as well, and upon digging in I found that it was because I was calling request.promise() twice. Turns out that promise() calls request.runTo, which does not play nice on multiple calls because it will cause the state machine to transition with the same state twice. If that state happens to be send, then it will hit the event listener for send twice. That will make two network requests with the same request & response object. Naturally, one will complete first and delete the buffers. When the second one completes, the buffers won't exist anymore and that's where you get the Cannot read property 'push' of undefined error.
It would be nice if there was some logic to prevent running the state machine twice, as this was not an easy bug to track down. Especially since I don't see anything in the docs that says "btw if you call promise() twice you're taking a trip to crazytown".
I would also believe that there are cases where runTo() is called from one of the other locations and then calling promise() once is enough to hose you.
Thanks so much @stevearc. This exactly describes the errors I've been seeing. So, for instance I'm grabbing some items from s3, and using Promise.all to collect the items and do something with them in a lambda. If I'm mapping over a collection of params items, feeding each of those into s3.getObject, then calling promise() on each of those to generate an array of promises for Promise.all, I'd run into this problem, correct?
I am running into the same issue. Where I await on a Promise.all, curious if this is the same problem.
Ran into the same issue using a promise that wrapped the promise from request.promise(). Issue was resolved by switching to callbacks. I'd recommend just using the callback and wrapping it in a promise to use this without issue until this is resolved.
let promise = new Promise((resolve, reject) => {
docClient.put(putParams, (err, data) => {
if (err) {
reject(err)
} else {
resolve(data)
}
});
});
@softprops
Did you have any followup questions? Between the change by @chrisradek and suggestion from @mdobro, I hope you were able to figure out a solution.
Closing out this issue. Let us know if you have anything additional to add.
I hit this error as well, and upon digging in I found that it was because I was calling
request.promise()twice. Turns out that promise() calls request.runTo, which does not play nice on multiple calls because it will cause the state machine to transition with the same state twice. If that state happens to besend, then it will hit the event listener for send twice. That will make two network requests with the same request & response object. Naturally, one will complete first and delete the buffers. When the second one completes, the buffers won't exist anymore and that's where you get theCannot read property 'push' of undefinederror.It would be nice if there was some logic to prevent running the state machine twice, as this was not an easy bug to track down. Especially since I don't see anything in the docs that says "btw if you call promise() twice you're taking a trip to crazytown".
I would also believe that there are cases where
runTo()is called from one of the other locations and then callingpromise()once is enough to hose you.
Is this issue solved? I'm hitting this issue with aws lambda.
Locking this thread as the issue is old, and resolved.
Please open a new issue for related bugs and link to relevant comments in this thread.
Most helpful comment
Ran into the same issue using a promise that wrapped the promise from request.promise(). Issue was resolved by switching to callbacks. I'd recommend just using the callback and wrapping it in a promise to use this without issue until this is resolved.