Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled "TypeError: Cannot read property 'message' of null" #708

Closed
jbuck opened this issue Sep 10, 2015 · 9 comments
Closed

Unhandled "TypeError: Cannot read property 'message' of null" #708

jbuck opened this issue Sep 10, 2015 · 9 comments
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.

Comments

@jbuck
Copy link

jbuck commented Sep 10, 2015

While using the AWS SDK v2.1.50 to delete a large number of files in S3 I sometimes encountered this error throwing from deep within the SDK

/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/util.js:612
      if (options.message)
                 ^

TypeError: Cannot read property 'message' of null
    at Object.error (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/util.js:612:18)
    at Request.callListeners (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:107:28)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:595:14)
    at Request.transition (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:21:10)
    at AcceptorStateMachine.runTo (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:37:9)
    at Request.<anonymous> (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:597:12)
    at Request.callListeners (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:115:18)

I looked at the code in question and I think it needs a null check, since typeof null === 'object'

@AdityaManohar
Copy link
Contributor

@jbuck Thanks for reporting this! Do you have a minimal reproduction test case that I can use to replication the problem. This is an easy fix, but I'm more curious about the origin of the error.

@jbuck
Copy link
Author

jbuck commented Sep 11, 2015

Sure! Here's the code that was throwing:

var async = require("async");
var AWS = require("aws-sdk");
var S3 = new AWS.S3();

var Bucket = process.argv[2];
var IsTruncated = true;
var KeyMarker;

async.whilst(function test() {
  return IsTruncated;
}, function workfn(callback) {
  var params = {
    Bucket,
    KeyMarker,
    MaxKeys: 1000
  };

  S3.listObjectVersions(params, function(list_error, data) {
    if (list_error) {
      return callback(list_error);
    }

    IsTruncated = data.IsTruncated;
    KeyMarker = data.NextKeyMarker;

    callback(null);
  });
}, function errfn(error) {
  throw error;
});

The bucket I was listing and deleting had around 400k objects, and I found that this error would occur more frequently near the end of the deletion run, after running for about 45 minutes. Only the listing code was throwing this error.

@jbuck
Copy link
Author

jbuck commented Sep 11, 2015

@AdityaManohar I ran it again today, happens in about 5 minutes now:

(assume-aws-role everything)$ time node bin/s3-delete-everything.js popcorn.webmadecontent.org
/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/util.js:612
      if (options.message)
                 ^

TypeError: Cannot read property 'message' of null
    at Object.error (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/util.js:612:18)
    at Request.callListeners (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:107:28)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:595:14)
    at Request.transition (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:21:10)
    at AcceptorStateMachine.runTo (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:37:9)
    at Request.<anonymous> (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:597:12)
    at Request.callListeners (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:115:18)

real    5m38.866s
user    1m26.354s
sys 0m2.013s

@AdityaManohar
Copy link
Contributor

@jbuck I've pushed up a fix that should resolve this issue. Let me know if this works for you.

Feel free to reopen this issue if you continue to have problems, and thanks for reporting!

@jbuck
Copy link
Author

jbuck commented Sep 12, 2015

Exciting, a new error! :)

/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:30
            throw err;
            ^

Error: null
    at Request.callListeners (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:107:43)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:595:14)
    at Request.transition (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:21:10)
    at AcceptorStateMachine.runTo (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:37:9)
    at Request.<anonymous> (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:597:12)
    at Request.callListeners (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/jbuck/Documents/Github/s3-delete-everything/node_modules/aws-sdk/lib/request.js:595:14)

I can reproduce this with the same script as above; is there any other information I can add to assist in debugging this issue?

AdityaManohar added a commit that referenced this issue Sep 15, 2015
@jbuck
Copy link
Author

jbuck commented Sep 16, 2015

@AdityaManohar would you like me to refile this as a new issue? It's definitely better than before, since I can actually catch and retry the command, but there's no information about the error.

@AdityaManohar AdityaManohar reopened this Sep 21, 2015
@chrisradek
Copy link
Contributor

@jbuck
I was able to reproduce the new error you were seeing with the code you provided. It looks like the issue is actually with the callback function being supplied to async.whilst. Once the final listing returns, the test function will return false and the callback function will be called with null provided as the argument. Adding a check in the callback function for the existence of error before throwing it should (hopefully) resolve your issue.

Let me know if that helps!

@chrisradek chrisradek added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 13, 2015
@jbuck
Copy link
Author

jbuck commented Oct 14, 2015

Well, I'm a moron 😭

Thanks for fixing the original issue though, happy that the second one is my fault!

@jbuck jbuck closed this as completed Oct 14, 2015
@srchase srchase added the guidance Question that needs advice or information. label Dec 26, 2018
@lock
Copy link

lock bot commented Sep 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

4 participants