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
{{ message }}
Repository navigation
Error parsing JSON, possible attempt to deserialize HTML #1505
Looks to me like we're attempting to parse HTML as JSON somewhere in the app.
version: 0.5.3
osVersion: Windows 6.1.7601
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at file:///app/renderer.js:3:77588
at XMLHttpRequest.J.ae.onreadystatechange (file:///app/renderer.js:3:74786)
We're seeing some other variations on this as well:
SyntaxError: Unexpected token � in JSON at position 0
at JSON.parse (<anonymous>)
at file:///app/renderer.js:3:77567
at XMLHttpRequest.J.ae.onreadystatechange (file:///app/renderer.js:3:74765)
SyntaxError: Unexpected token : in JSON at position 0
at JSON.parse (<anonymous>)
at file:///app/renderer.js:3:77567
at XMLHttpRequest.J.ae.onreadystatechange (file:///app/renderer.js:3:74765)
And then I realised there's a subtle error in here. ajaxConfig.dataType is set by octokat.js as part of what it thinks is the expected response, but for non-JSON results this value isn't going to reflect reality. I thought jqXHR.dataType would reflect reality but that's also set by the library.
The Correct Way™ would be for the callback to look at the response header, and that seems fine as per the dev tools:
I'd put together a patch for this but it looks like an update for octokat.js is imminent which has rewritten the requester code to this:
// Convert to JSON if we are expecting JSON// TODO: use a blob if we are expecting a binaryif(!options.isRaw){dataPromise=response.json()}else{dataPromise=response.text()}
This seems a bit more resilient, but I'm not 100% confident on that given how it still relies on options rather than poking at the response, so I'm testing this as a scoped package and poking around to see if there's anything else I can provide upstream.
I'm experimenting with a scoped package based on the upcoming 0.9.0 release of Octokat.js and philschatz/octokat.js#172 which should improve this situation:
The additional changes coming with 0.9.0 make me think we should do a bit more testing but let me know your feels on this @desktop/core if you think we should get this into an update sooner.
I'm fine with updating to 0.9.x once your PR lands to get this fixed. It's one of our most common haystack reports, but we don't have users banging down the door about it 🤷♂️
Activity
shiftkey commentedon May 17, 2017
Disassembling the release app suggests it's the usage inside Octokat.js: https://github.com/philschatz/octokat.js/blob/master/src/requester.js#L177
Without more context, the 500ing of
/user/public_emailsis probably my best guess of the root cause, which is #1508.@niik any objections to closing this as a dupe of #1508?
shiftkey commentedon May 18, 2017
Closing this out as a dupe of #1508.
Reopen if we find another API call that fails in this way that tries to parse HTML as JSON.
joshaber commentedon May 18, 2017
This is still happening in 0.5.5: https://haystack.githubapp.com/desktop/needles/HxyELOY8y9Ul5-Ui-N3ZVw
joshaber commentedon May 18, 2017
We're seeing some other variations on this as well:
shiftkey commentedon May 25, 2017
Went back to this one this morning and found myself staring at this snippet again in the octokat.js requester:
And then I realised there's a subtle error in here.
ajaxConfig.dataTypeis set by octokat.js as part of what it thinks is the expected response, but for non-JSON results this value isn't going to reflect reality. I thoughtjqXHR.dataTypewould reflect reality but that's also set by the library.The Correct Way™ would be for the callback to look at the response header, and that seems fine as per the dev tools:
I'd put together a patch for this but it looks like an update for octokat.js is imminent which has rewritten the requester code to this:
This seems a bit more resilient, but I'm not 100% confident on that given how it still relies on
optionsrather than poking at the response, so I'm testing this as a scoped package and poking around to see if there's anything else I can provide upstream.shiftkey commentedon May 25, 2017
I'm experimenting with a scoped package based on the upcoming
0.9.0release of Octokat.js and philschatz/octokat.js#172 which should improve this situation:The additional changes coming with
0.9.0make me think we should do a bit more testing but let me know your feels on this @desktop/core if you think we should get this into an update sooner.joshaber commentedon May 25, 2017
I'm fine with updating to 0.9.x once your PR lands to get this fixed. It's one of our most common haystack reports, but we don't have users banging down the door about it 🤷♂️