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

Fix to prevent sync.services deprecation notice #487

Merged

Conversation

stevennic-twilio
Copy link
Contributor

While using Twilio-node v4.x+ in a Function, calling getSync(<ServiceName>) also prints out the warning services is deprecated. Use v1.services instead..

These PR simply adds .v1 to the existing client.sync.services[...] code.

The current default Twilio-node version for new Serverless Services (v3.29.2) does appear to include the option for client.sync.v1.services[...] as well.

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

Copy link

changeset-bot bot commented Nov 29, 2023

🦋 Changeset detected

Latest commit: 0788014

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@twilio/runtime-handler Patch
twilio-run Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@victoray
Copy link
Contributor

hey @stevennic-twilio, thanks for the PR, twilio-node has been bumped to v4, we can close this now.

@victoray victoray closed this Mar 22, 2024
@stevennic-twilio stevennic-twilio deleted the SyncV1ServicesDeprecationWarning branch March 24, 2024 13:03
@stevennic-twilio stevennic-twilio restored the SyncV1ServicesDeprecationWarning branch March 24, 2024 14:15
@stevennic-twilio
Copy link
Contributor Author

Hi @victoray,

I did re-run a check on a local project with the updated dependencies released earlier (@twilio/runtime-handler, twilio, twilio-run, etc).

The deprecation notice is version agnostic and does appear in the latest version of the twilio-node helper library (ref: https://github.com/twilio/twilio-node/blob/main/src/rest/Sync.ts#L9) and the services is deprecated. Use v1.services instead. alert does appear with all of the updated package versions.

Minimal steps to reproduce:

  • twilio serverless:init serverless-toolkit-487
  • cd serverless-toolkit-487
  • Update packages.json to reference v4.0.0 of twilio-run and v4.23.0 of twilio
[...]
  "dependencies": {
    "@twilio/runtime-handler": "2.0.0",
    "twilio": "^4.23.0"
  },
  "devDependencies": {
    "twilio-run": "4.0.0"
  },
[...]
  • Run npm install
  • Update hello-world.js to match below:
exports.handler = function(context, event, callback) {
  const twiml = new Twilio.twiml.VoiceResponse();

  sync = Runtime.getSync();

  twiml.say('Hello World!');
  callback(null, twiml);
};
  • Run npm run start
  • Access localhost:3000/hello-world

Expected result: The following log output:

200 GET /hello-world │ Response Type text/xml; charset=utf-8

Actual result: The following log output:

services is deprecated. Use v1.services instead.
200 GET /hello-world │ Response Type text/xml; charset=utf-8

Workaround for local environment:

  • Stop server (if still running from before)
  • Open node_modules/@twilio/runtime-handler/dist/dev-runtime/internal/runtime.js
  • Update line 55 to include .v1 as referenced in the pull request code
  • Save file
  • Run server again with npm run start
  • Access localhost:3000/hello-world and check log output again

In my testing, the workaround above only works for local testing. While deployed, the alert will remain.

@victoray victoray reopened this Mar 25, 2024
@victoray
Copy link
Contributor

victoray commented Apr 3, 2024

hi @stevennic-twilio, can you add a changeset to this PR ?

fix(twilio-run): add changeset
@victoray victoray merged commit cdf9e3a into twilio-labs:main Apr 4, 2024
10 checks passed
Copy link

welcome bot commented Apr 4, 2024

Congratulations on your first contribution to the Serverless Toolkit!
If you are on the look out for more ways to contribute to open-source, check out a list of some of our repositories at https://github.com/twilio/opensource.
If you want to stay up-to-date with Twilio's OSS activities, subscribe here: https://twil.io/oss-updates
And if you love Twilio as much as we do, make sure to check out our Twilio Champions program!

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

Successfully merging this pull request may close these issues.

2 participants