ews-javascript-api icon indicating copy to clipboard operation
ews-javascript-api copied to clipboard

unhandled rejection: cannot read property 'documentElement'

Open PhilHannent opened this issue 4 years ago • 8 comments

Randomly I get an error in the library, it is not something I can reproduce because it happens randomly.

app.js: unhandledRejection] Root RejectionTypeError: Cannot read property 'documentElement' of undefined at EwsServiceXmlReader.EwsXmlReader (C:\inetpub\src\js\Core\EwsXmlReader.ts:43:57) at new EwsServiceXmlReader (C:\inetpub\src\js\Core\EwsServiceXmlReader.ts:18:9) at FindItemRequest.ServiceRequestBase.ProcessWebException (C:\inetpub\src\js\Core\Requests\ServiceRequestBase.ts:315:30) at C:\inetpub\src\js\Core\Requests\SimpleServiceRequestBase.ts:71:55 at tryCatcher (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\promise.js:547:31) at Promise._settlePromise (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\promise.js:604:18) at Promise._settlePromise0 (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\promise.js:649:10) at Promise._settlePromises (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\promise.js:725:18) at _drainQueueStep (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\async.js:93:12) at _drainQueue (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\async.js:86:9) at Async._drainQueues (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (C:\inetpub\room-booking-api-prod\node_modules\bluebird\js\release\async.js:15:14) at processImmediate (internal/timers.js:456:21)

PhilHannent avatar Aug 04 '20 06:08 PhilHannent

We're running v0.10.2

PhilHannent avatar Aug 04 '20 06:08 PhilHannent

are you running behind a proxy or anything, seems like randomly the response is not of type xml.

gautamsi avatar Aug 04 '20 06:08 gautamsi

It is not behind a proxy, we connect to a range of customers EWS servers and O365.

PhilHannent avatar Aug 04 '20 06:08 PhilHannent

this is definitely some kid of situation where there is some invalid xml coming up. do you know which function it may be breaking or is this random?

gautamsi avatar Aug 04 '20 07:08 gautamsi

I don't have enough information available to me.

I know that we use a lot of FindAppointments() but that we also call Update() on an Appointment. I'd be willing to be 99% it is either of those.

PhilHannent avatar Aug 04 '20 08:08 PhilHannent

I was wondering if any solution on this issue

ghost avatar Dec 29 '20 07:12 ghost

@JojiePalahang let me know if you have any details on this.

  • version
  • call to ews (like FindFolder, Load etc)
  • sample code to reproduce this
  • is this happening all the time or only intermittent

any other information if you feel required for troubleshooting.

gautamsi avatar Dec 29 '20 08:12 gautamsi

My workaround for this was to put a try catch in the constructor and an if statement to protect the documentElement. Office 365 have reverse proxies which occasionally (once a week) spit out error HTML, the XML parser fails but there is no check in this constructor for if the document exists:

https://github.com/gautamsi/ews-javascript-api/blob/ef1ff64aa470bd354089bcd5ea2123b87facc5fe/src/js/Core/EwsXmlReader.ts#L39

Sorry, I should have reported back sooner.

PhilHannent avatar Dec 29 '20 10:12 PhilHannent