Using Codegen to automate the conversion of 592 instances of Promise .then
chains to async/await
in Twilio’s Node.js Repository
.then()
chains often lead to nested, hard-to-read code. While async/await
offers a cleaner alternative, migrating large codebases like Twilio’s Node.js SDK requires careful handling of backward compatibility.
Using Codegen, we performed this conversion reliably across all 592 instances.
operationPromise
setPromiseCallback
convert_to_async_await()
api.
TSFunction.promise_chains
method.
setPromiseCallback
utility.then()
syntax often leads to complex and deeply nested code that’s harder to maintain. It’s an active problem that many teams want to pursue but never end up doing so due to the time consuming nature of the migration.
Codegen can significantly accelerate these migrations by automating the conversion for several different cases.
Want to try this yourself? Check out our Promise to Async/Await tutorial