twilio / twilio-node

Node.js helper library
MIT License
1.39k stars 509 forks source link

Latest dayjs version causes exception in client.messages.create() #934

Closed pwiebe closed 1 year ago

pwiebe commented 1 year ago

Issue Summary

Calling client.messages.create() using version 1.11.7 of dayjs throws an exception as shown below. Downgrading to version 1.11.5 resolves the issue.

Steps to Reproduce

  1. send a message using client.messages.create() as shown in the code snippet

Code Snippet

const twilio = require('twilio');
const client = twilio(ACCOUNT_SID, AUTH_TOKEN);

try {
        const result = await client.messages.create({
            to,
            from,
            body,
            statusCallback,
        });
        return result;
} catch (e) {
        console.log(e.message, e.stack);
}

Exception/Log

TypeError: Cannot read properties of null (reading 'constructor')
    at M.r (/Users/node_modules/dayjs/plugin/objectSupport.js:1:412)
    at M.parse (/Users//node_modules/dayjs/plugin/objectSupport.js:1:887)
    at new M (/Users/node_modules/dayjs/dayjs.min.js:1:2038)
    at Function.utc (/Users/node_modules/dayjs/plugin/utc.js:1:402)
    at parseDate (/Users/node_modules/twilio/lib/base/deserialize.js:64:29)
    at Object.rfc2822DateTime (/Users/node_modules/twilio/lib/base/deserialize.js:40:12)
    at new MessageInstance (/Users/node_modules/twilio/lib/rest/api/v2010/account/message.js:126:37)
    at /Users/node_modules/twilio/lib/rest/api/v2010/account/message.js:279:63
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Technical details:

AsabuHere commented 1 year ago

Hi @pwiebe, Thanks for the heads up! I tried reproducing this issue, and this works with the latest version 4.11.0. Can you please try the same code with the latest version of twilio?

Amogh-Gopinathan commented 1 year ago

@AsabuHere I'm getting this error 'TypeError: dayjs_1.default.utc is not a function' \node_modules\twilio\lib\base\deserialize.js:64:29

charan678 commented 1 year ago

Hello @pwiebe I was checking change logs for dayjs, I found they made changes with objectSupport. People has commented for null values issue there. You can have a look into this link. Let see if they are going to fix this in upcoming releases

titanism commented 1 year ago

We submitted a pull request https://github.com/iamkun/dayjs/pull/2342 and will reach out to the author

titanism commented 1 year ago

Our PR was merged, we are waiting on a new release of dayjs.

titanism commented 1 year ago

v1.11.9 of dayjs was released at https://github.com/iamkun/dayjs/issues/2277#issuecomment-1615405772

please close this issue as this is now resolved

titanism commented 1 year ago

@AsabuHere please see https://github.com/twilio/twilio-node/pull/945

AsabuHere commented 1 year ago

Hi @titanism, Thanks for raising the PR to update the dayjs version. Our team has reviewed and merged the PR.

@pwiebe Please verify the fix using the updated version of dayjs, and feel free to open a new github issue if the issue still persists