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

context.getTwilioClient() error #458

Closed
deshartman opened this issue Feb 1, 2023 · 3 comments
Closed

context.getTwilioClient() error #458

deshartman opened this issue Feb 1, 2023 · 3 comments

Comments

@deshartman
Copy link

deshartman commented Feb 1, 2023

I have hit an issue with context.getTwilioClient(). I have used it in the past, but now I get the below error from the simple code below. Can someone please help me out here to narrow down the issue. I have included my package.json file for ref.

exports.handler = async (context, event, callback) => {

    const restClient = context.getTwilioClient();

    return callback(null, { hello: 'world' });
}

This is the error when running this. (I'm using ngrok locally)

/Users/dhartman/Development/01_Twilio/twilio-stack/twilio-stack-server/node_modules/@twilio/runtime-handler/dist/dev-runtime/checks/check-auth-token.js:30
        (_a = options.logger) === null || _a === void 0 ? void 0 : _a.error(message, title);
                                                                      ^

TypeError: _a.error is not a function
    at Object.checkForValidAuthToken (/Users/dhartman/Development/01_Twilio/twilio-stack/twilio-stack-server/node_modules/@twilio/runtime-handler/dist/dev-runtime/checks/check-auth-token.js:30:71)
    at Object.getTwilioClient (/Users/dhartman/Development/01_Twilio/twilio-stack/twilio-stack-server/node_modules/@twilio/runtime-handler/dist/dev-runtime/route.js:124:28)
    at exports.handler (/Users/dhartman/Development/01_Twilio/twilio-stack/twilio-stack-server/functions/getJSONData.js:16:32)
    at process.<anonymous> (/Users/dhartman/Development/01_Twilio/twilio-stack/twilio-stack-server/node_modules/@twilio/runtime-handler/dist/dev-runtime/internal/functionRunner.js:74:9)
    at process.emit (node:events:527:28)
    at emit (node:internal/child_process:938:14)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

My package.json file

  "name": "twilio-stack-server",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "twilio-run",
    "deploy": "twilio-run deploy"
  },
  "dependencies": {
    "@twilio/runtime-handler": "1.3.0",
    "twilio": "^3.56"
  },
  "devDependencies": {
    "twilio-run": "^3.5.2"
  },
  "engines": {
    "node": "16"
  }
}```

@deshartman
Copy link
Author

Here is a simple gitHub example

https://github.com/deshartman/simple-serverless

@dkundel
Copy link
Member

dkundel commented Feb 1, 2023

Hi Des!

So the error is indeed odd. It looks like the logger instance is not appropriately passed through. I have to investigate a bit more. What's happening is that you are trying to create a client but your .env file doesn't contain an AUTH_TOKEN so the check is trying to throw an error to let you know but it's failing because it can't access the logger method correctly.

I'll dig more into why that's happening in the coming days. Thanks for filing this

@deshartman
Copy link
Author

Bugger!

Can't believe I missed that. I went and check older projects where this works and they have the AUTH_TOKEN. Thanks for the point out.

I guess the error does point this out in hindsight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants