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 'ResponseClass' of undefined #378

Open
marcoancona opened this issue Apr 11, 2021 · 6 comments
Open

Cannot read property 'ResponseClass' of undefined #378

marcoancona opened this issue Apr 11, 2021 · 6 comments

Comments

@marcoancona
Copy link
Contributor

marcoancona commented Apr 11, 2021

Hi @gautamsi,
some (but not all) of our users report a crash while synchronizing their Office 365 account. We could not reproduce the issue with out test account, but our logs show the following error:

TypeError: Cannot read property 'ResponseClass' of undefined
    at t.e.LoadFromXmlJsObject (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:1032676)
    at t.ParseResponseXMLJsObject (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:872562)
    at t.ParseResponse (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:873117)
    at t.e.ReadResponseXmlJsObject (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:898658)
    at t.ReadResponsePrivate (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:917307)
    at /opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:916675
    at c (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:111685)
    at R._settlePromiseFromHandler (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:79811)
    at R._settlePromise (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:80611)
    at R._settlePromise0 (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:81310)
    at R._settlePromises (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:82662)
    at c (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:25167)
    at a (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:25106)
    at i._drainQueues (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:26232)
    at drainQueues (/opt/Morgen/resources/app.asar/extensions/mo-ews-sync/dist/background.js:25:25040)

Running in debug mode, it looks like the parsing of an event is interrupted abruptly but I can't see the reason:

... other 75 events correctly parsed before ...
background.js:337 [t] 		Loading property :		Subject
background.js:337 Panel Zoom Interview
background.js:337 [t] 		Loading property :		Sensitivity
background.js:337 0
background.js:337 [t] 		Loading property :		Body
background.js:337 t {Namespace: 2, OnChange: Array(1), bodyType: 1, text: null}
background.js:337 [mo-ews-sync] Exception: The request failed. Cannot read property 'ResponseClass' of undefined

I understand that this is not very complete information but I was wondering if you any idea of where to look in order to debug this.

ews-javascript-api: 0.10.3

@gautamsi
Copy link
Owner

Is this trying to load event from calendar?

Based on log can you export the item which has issues?

Also I see that it may be minified lib, can you exclude ews lib from being minified and test again?

@marcoancona
Copy link
Contributor Author

marcoancona commented Apr 13, 2021

We investigated further. It turns out that one event has an invalid character in the Body field. The Body looks like the following:

<Body BodyType="Text">
Hi all,&#xD;↵&#xD;↵I need one more acceptance. The candidate&#x1B;$B!G&#x1B;(Bs profile opens. 
</Body>

The problem appears to be with the sequence &#x1B;, which makes the parsing fail. For a reproducible example see: https://codesandbox.io/s/quirky-worker-brfng?file=/src/index.js

Note 1): this does not fail on a Node environment. I suspect that DOMParser works differently than xmldom.
Note 2): issue reproducible on any browser console: (new DOMParser()).parseFromString("<Body>Test &#x1B;</Body>", "text/xml")

@gautamsi
Copy link
Owner

which build you are using for browser?

@marcoancona
Copy link
Contributor Author

We are using ews-javascript-api 0.10.3 (the latest). Or what version are you referring to?

@marcoancona
Copy link
Contributor Author

marcoancona commented Apr 13, 2021

Just to clarify: the problem seems really to be caused by invalid XML data coming from the Outlook server. It appears that xmldom is more robust than the native DOMParser of Chromium when parsing invalid XML.

This is what happens in Chrome:
image

When we use ews-javascript-api, either xmldom or DOMParser is used to parse the response. Which one is used depends on the environment (

).

We will temporarily patch the library to force it to use xmldom even in the browser, unless you tell us that this is not a good idea.

@gautamsi
Copy link
Owner

Try patching for xmldom that should work

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