Resolve issues with "[github assistant] undefined" #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
Should help with (if not fix) #135 and #142
Since I also got the
[github assistant] undefinederror from time to time, I took the time do dig into it a little more.In my case the issue most often appeared during
pulloperations (since I don't push often) and was usually resolved by reloading the page or something like that (so the GitHub token is fine and Script API is working).Using the Chrome Developer Tools, I was able to pin down the call in
script-api.js, that produced this unhelpful error message. At its core, it was doing something likeThe problem is, that the AJAX call always returns a
jqXHRobject, which has nomessageproperty. The changes toscript-api.jsretrieve a meaningful error message from the object.With the error messages I was able to identify the problems I was having:
not bad, just fix the code
definitely needed some investigation
After checking the requests I could see, that some files where duplicated within the request - exactly those producing the error message. So I looked into the creation of the file list and the duplicates were already in the initial list:
This was caused by a duplication of the diff modal, that is shown to the user to select which files he wants to keep. If there are two or more instances of this modal, than the code line above will find two or more checkboxes per file and add those to the list of files.
The duplicate modals seem to be created when the user switches between the editor and the other pages - which is why a reload usually helped. I added a check to the corresponding function in
gas-hub.jsto prevent multiple modals.