The dreaded 500 error issue

hi

I love your project - however I keep on getting this 500 error. I updated to the latest Node version and added the console.log to the catch section. I tried creating a new user as well. I’ve included the code . Any help would be greatly appreciated as I am a newbie. This was the first snag I had.

Is this section important? in other words can I run this app if I don’t solve this issue.

Anthony

serverless invoke local --function create --path mocks/create-event.json

Serverless: Bundling with Webpack...

[hardsource:ba6f7c72] Could not freeze /Users/(MY NAME)/notes-app-api/create.js: Cannot read property 'hash' of undefined

ResourceNotFoundException: Requested resource not found

    at Request.extractError (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/protocol/json.js:51:27)

    at Request.callListeners (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:106:20)

    at Request.emit (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:78:10)

    at Request.emit (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:683:14)

    at Request.transition (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)

    at AcceptorStateMachine.runTo (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)

    at /Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10

    at Request.<anonymous> (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)

    at Request.<anonymous> (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:685:12)

    at Request.callListeners (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:116:18)

    at Request.emit (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:78:10)

    at Request.emit (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:683:14)

    at Request.transition (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)

    at AcceptorStateMachine.runTo (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)

    at /Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10

    at Request.<anonymous> (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)

    at Request.<anonymous> (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/request.js:685:12)

    at Request.callListeners (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:116:18)

    at callNextListener (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:96:12)

    at IncomingMessage.onEnd (/Users/anthonywilliams/notes-app-api/node_modules/aws-sdk/lib/event_listeners.js:307:13)

    at IncomingMessage.emit (events.js:215:7)

    at IncomingMessage.EventEmitter.emit (domain.js:476:20)

    at endReadableNT (_stream_readable.js:1183:12)

    at processTicksAndRejections (internal/process/task_queues.js:80:21) {

  message: 'Requested resource not found',

  code: 'ResourceNotFoundException',

  time: 2019-10-09T04:01:55.217Z,

  requestId: 'II4CVD786MS0MBL0KO7T6P767FVV4KQNSO5AEMVJF66Q9ASUAAJG',

  statusCode: 400,

  retryable: false,

  retryDelay: 40.27416882981337

}

{

    "statusCode": 500,

    "headers": {

        "Access-Control-Allow-Origin": "*",

        "Access-Control-Allow-Credentials": true

    },

    "body": "{\"status\":false}"

For the 500 error, specifically the ones with status: false, you can debug them relatively easily because we are returning these errors in the code.

In this case, add a console.log(e) above this line to see what the error is:

i did that and got the same error message.

Oh what was the actual error message?

@jayair

I got this error at console:-

[hardsource:36e03175] Could not freeze C:/notes-app-api/get.js: Cannot read property 'hash' of undefined
{
    "statusCode": 500,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"status\":false,\"error\":\"Item not found.\"}"
}

Any help appreciated!

So you can ignore the hardsource warning. But for the error itself, add a console.log(e) in your Lambda function before it calls the failure line. Check out the snippet I posted above.