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

Excel process crashes after getting a response #422

Open
eekboom opened this issue Nov 14, 2019 · 3 comments
Open

Excel process crashes after getting a response #422

eekboom opened this issue Nov 14, 2019 · 3 comments

Comments

@eekboom
Copy link

eekboom commented Nov 14, 2019

We have a strange problem on only some computers:
After a response has been received, Excel completely crashes. It vanishes, restarts and offers to recover the previous file. On these machines, it happens each and every time.
On other machines, it works perfectly.

We added some logging that can be seen in the Immediate window, so we know that the response was already received successully.

A second or so after that, Excel just quits.

Of course, I have already googled a lot and found mostly other people having the same problem, but no fix.

Maybe you have an idea what I could try?

This is "Excel for Office 365 MSO (16.0.12130.20272) 64-bit" on "Windows 10 Pro 17134.1006".
In the event log I see this
grafik

@zgrose
Copy link

zgrose commented Nov 14, 2019

I've noticed crashes when I try to parse large (unexpected) HTML pages rather than the expected JSON response. Usually I get those large HTML pages when the server send back the developer exception page at me.

You might want to dump the responses to a text file prior to parsing to see if you're getting what you think you're getting.

@eekboom
Copy link
Author

eekboom commented Nov 22, 2019

Pheeeew. That was an ordeal!
Finally figured out what triggered this.
It only happens with Excel 16.0.12130.20272
I had to use a VM to experiment and the Office Deployment Tool to have exactly that version installed.

Then a lot more of trial and error to find out that the following code triggered it.
I wrote a little helper function that should extract a field of a JSON response and return an empty string if it isn't included in the server response:

...
    Dim Response As WebResponse
    Dim Message As String

    Set Response = Client.Execute(Request)
    Set ResponseData = Response.Data
    Message = GetResponseMessage(ResponseData)
...
Function GetResponseMessage(ResponseData As Variant) As String
    On Error GoTo getResponseMessage_ErrorHandling
    GetResponseMessage = ResponseData("message")
    Exit Function
    
getResponseMessage_ErrorHandling:
    GetResponseMessage = ""
End Function

This works on all of our machines and many different Excel version, but always crashes on all the machines of our client's client' machines with that specific Excel version - regardless of whether the server response actually has the "message" field included.

I changed the code to the following and now it works:

...
    Dim Response As WebResponse
    Dim Message As String

    Set Response = Client.Execute(Request)
    Message = GetResponseMessage(Response)
...
Function GetResponseMessage(Response As WebResponse) As String
    On Error GoTo getResponseMessage_ErrorHandling
    GetResponseMessage = Response.Data("message")
    Exit Function

getResponseMessage_ErrorHandling:
    GetResponseMessage = ""
End Function

@ruuttt
Copy link

ruuttt commented Mar 22, 2023

I noticed Excel crashed after using the request object for the second request. This fixed the issue::
Set Request = New WebRequest

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

3 participants