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

Cannot read property 'ok' of undefined in sendwithus.js #64

Closed
thomasInes opened this issue Dec 12, 2022 · 6 comments · Fixed by #65
Closed

Cannot read property 'ok' of undefined in sendwithus.js #64

thomasInes opened this issue Dec 12, 2022 · 6 comments · Fixed by #65

Comments

@thomasInes
Copy link

thomasInes commented Dec 12, 2022

Hi,

does the API have an issue this morning?
The library has started to throw errors in our app. It seems the API is not sending what the library expects (cf error below).
We didn't observe this behavior with this version of the library before.
Thank you :)

Client version

6.0.1

Expected behaviour

no error thrown

Actual behaviour

error being thrown by the library:

{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "TypeError: Cannot read property 'ok' of undefined",
    "reason": {
        "errorType": "TypeError",
        "errorMessage": "Cannot read property 'ok' of undefined",
        "stack": [
            "TypeError: Cannot read property 'ok' of undefined",
            "    at Sendwithus._handleResponse (/var/task/node_modules/sendwithus/lib/sendwithus.js:122:23)",
            "    at /var/task/node_modules/sendwithus/lib/sendwithus.js:91:63",
            "    at propagateAslWrapper (/var/task/node_modules/async-listener/index.js:504:23)",
            "    at proxyWrapper (/var/task/node_modules/async-listener/index.js:531:16)",
            "    at /var/task/node_modules/async-listener/index.js:541:70",
            "    at /var/task/node_modules/async-listener/glue.js:188:31",
            "    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
        ]
    },
    "promise": {},
    "stack": [
        "Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'ok' of undefined",
        "    at process.<anonymous> (/var/runtime/index.js:35:15)",
        "    at process.emit (events.js:314:20)",
        "    at process.EventEmitter.emit (domain.js:483:12)",
        "    at processPromiseRejections (internal/process/promises.js:209:33)",
        "    at processTicksAndRejections (internal/process/task_queues.js:98:32)"
    ]
}

Steps to reproduce

not sure. either calling send or render

@demoore
Copy link
Member

demoore commented Dec 12, 2022

Hmm, this could be a result of an issue on the API or network issue, but I think something else is going on. We're taking a look. Thanks for reporting this!

demoore added a commit that referenced this issue Dec 12, 2022
Adds the response object to the success condition callback
@thomasInes
Copy link
Author

thomasInes commented Dec 12, 2022

@demoore thanks for looking into this.
FWI, if that can help, the emails related to these calls seem to have been processed and sent successfully by SWU.

edit: Please ignore. Our app has a retry mechanism. The emails were processed succesfully on the 2nd call

@demoore demoore mentioned this issue Dec 12, 2022
8 tasks
demoore added a commit that referenced this issue Dec 12, 2022
Adds the response object to the success condition callback
@demoore
Copy link
Member

demoore commented Dec 12, 2022

No worries @thomasInes! We appreciate the report 😄

v6.0.2 was just pushed to npm if you want to give that a shot: https://www.npmjs.com/package/sendwithus

@thomasInes
Copy link
Author

Thank you @demoore. Will upgrade and monitor the lib's behavior.

Just out of curiosity though, if the issue is network or API related, how would your update help?
And if it not, should it not means the lib should error out all the time? In our case it errors out randomly (but more frequently these past few days). Just trying to understand.
Thanks again

@demoore
Copy link
Member

demoore commented Dec 12, 2022

I don't think it's network related. I was able to reproduce the same error with some pretty basic code:

api.render({ template: TEMPLATE_ID }, (r) => {
  console.log(r); // this worked
  console.log(Object.keys(r)); // this did NOT
});

I think this was happening in specific cases where the render/send callback was trying to access the response object. Without seeing your code it's tough to say for sure -- especially since we didn't have any API alarms go off.

Keep me posted on whether the issue persists! If so, we might have to get you to reach out to our support so we can trace your account.

@thomasInes
Copy link
Author

Thank you. Will keep you posted

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 a pull request may close this issue.

2 participants