You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In case of a client side network error the returned error message is "Unexpected Error" instead of "Network Error".
Additionally a NPE will be logged in the console. (TypeError: Cannot read properties of null (reading 'getAllResponseHeaders'))
Expected behavior
A single error with the expected error message
Steps To Reproduce
Open DevTools
Go to Network tab
Set mode to offline
Send request
Your Setup:
Chrome 114.0.5735.111
Dynamics 365 Online
Additional context
The problem is the incorrect error handling in case of a network error.
In case of client side network errors the request will be instantly completed with a status of 0. As such the onreadystatechange function is called with readyState 4 and request.status 0. The library then fails to parse the response and returns an error message of "Unexpected Error". And dereferences the request.
After that the onerror function is called which then errors out due to a NPE.
The correct handling would be to explicitly ignore a request.status of 0 in onreadystatechange function. In these cases the onerror function will be called.
DynamicsWebApi version
For example: v1.7.6
Describe the bug
In case of a client side network error the returned error message is "Unexpected Error" instead of "Network Error".
Additionally a NPE will be logged in the console. (TypeError: Cannot read properties of null (reading 'getAllResponseHeaders'))
Expected behavior
A single error with the expected error message
Steps To Reproduce
Your Setup:
Additional context
The problem is the incorrect error handling in case of a network error.
In case of client side network errors the request will be instantly completed with a status of 0. As such the onreadystatechange function is called with readyState 4 and request.status 0. The library then fails to parse the response and returns an error message of "Unexpected Error". And dereferences the request.
After that the onerror function is called which then errors out due to a NPE.
The correct handling would be to explicitly ignore a request.status of 0 in onreadystatechange function. In these cases the onerror function will be called.
From https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/status:
The text was updated successfully, but these errors were encountered: