SO-Close-Vote-Reviewers / UserScripts

Various user scripts that add features to the review queue or to the chat room
Other
57 stars 40 forks source link

CV Request Generator: "Failed retrieving room name. Is it a valid room?" error #164

Closed armujahid closed 5 years ago

armujahid commented 5 years ago

I am using Stack Exchange CV Request Generator v1.6.6. I randomly get this error message "Failed retrieving room name. Is it a valid room?" whenever a question is opened. image

double-beep commented 5 years ago

More details are needed to reproduce your problem. Currently, I have no idea what you are asking: maybe you mean that when a question is loaded, you get this message on the top of the page?

armujahid commented 5 years ago

yes exactly. I randomly get this error on the top of the page when a question is loaded. I will gather more data if it occurs again. May be room fetching AJAX request from userscript fails randomly.

Chrome: v74.0.3729.131 (Official Build) (64-bit) Tampermonkey: v4.8

You can close this issue for now if you like.

armujahid commented 5 years ago

I am closing this since it's no longer occurring. I have also tested it with greasemonkey on Firefox. May be it was my environment specific issue.

armujahid commented 5 years ago

Since today I have been facing this issue again. image

Console Error:

ReferenceError: "StackExchange is not defined"
    userScript user-script:http%3A//github.com/SO-Close-Vote-Reviewers/UserScripts/Magic%u2122Editor/Magic%u2122Editor:3964
    userScript user-script:http%3A//github.com/SO-Close-Vote-Reviewers/UserScripts/Magic%u2122Editor/Magic%u2122Editor:4010
    scopeWrapper user-script:http%3A//github.com/SO-Close-Vote-Reviewers/UserScripts/Magic%u2122Editor/Magic%u2122Editor:4082
    <anonymous> user-script:http%3A//github.com/SO-Close-Vote-Reviewers/UserScripts/Magic%u2122Editor/Magic%u2122Editor:4083

Note that StackExchange is defined if I check it in console. May be script is trying to use StackExchange before it's definition. I can't see any AJAX call error.

makyen commented 5 years ago

@armujahid The error text you've included above is actually a different error on a different script, Magic Editor. For that problem, I've created issue #168 Magic Editor is not compatible with Greasemonkey 4.x.

Your screenshot does show that the problem you've reported here in this issue did occur again. However, it also indicates that some of the information you've provided above is inaccurate. That screenshot is from Firefox, not Chrome, and that you are using Greasemonkey, not Tampermonkey. Please provide updated information as to which browser, userscript manager, and script version you are using.

Note: It's not surprising that StackExchange would be defined in the console while not in the script. A) As you surmise, the script runs much earlier than when you run the command in the console. However, that possibility is handled in all but Greasemonkey 4 by settings used in the userscript. Unfortunately, Greasemonkey 4 either doesn't obey those settings, has chosen to ignore them, or interprets them differently (depending on which parts are being considered and how you want to look at it). B) In Greasemonkey, the script runs in a significantly different context than the console does. The context in which the script runs is not the same as the one in which in-page scripts run (and in which the console runs) and thus variables like StackExchange are not available to the userscript.

BTW: I recommend against using Greasemonkey 4. It just has too many incompatibilities with existing userscripts and it's likely that new scripts will be written without considering those incompatibilities. While some of those incompatibilities have been resolved or will be resolved over time, there are intentional incompatibilities which will never be resolved. If you choose to use Greasemonkey 4 you will have ongoing compatibility issues on random scripts for the foreseeable future. Currently, of the userscripts I use for Stack Exchange, 29 of them are known to be incompatible with Greasemonkey 4.

armujahid commented 5 years ago

Thank you for your detailed response. I didn't realize that console error was from Magic Editor. Yes you are right originally I faced this issue on chrome with tampermonkey at the time of reporting this issue (versions mentioned above). Currently I faced this issue Greasemonkey v4.9 on firefox with script v1.6.6.

I didn't know that Greasemonkey has compatibility issues. I am now switching to Tampermonkey on firefox. You can recommend any other better user script manager.

P.S: As mentioned in this comment it wasn't showing any warning on firefox before with Greasemonkey but I haven't properly tested this script functionality on firefox with Greasemonkey.

armujahid commented 5 years ago

I have migrated to Tampermonkey v4.9.5941 on Firefox. Console error is gone as you mentioned. but I am still getting this "Failed retrieving room name. Is it a valid room?" message without any console error.

image

NoScript isn't blocking any script since it's disabled for this tab.

All installed user scripts with version information: image

makyen commented 5 years ago

To get the error that you are seeing, the URL that it's using for the chat room has to at least look like it should be valid (the URL is tested to match a RegEx prior to use; failure would produce a different error), but an error has to have occurred when the script tried to fetch data from that URL. Assuming you haven't changed the room URL, the default URL it would use on Stack Overflow is:

https://chat.stackoverflow.com/rooms/41570/so-close-vote-reviewers

What extensions do you have installed? Do any of them block cross-site requests? Have you changed any of the networking default settings in Firefox? Do you have something on your network that blocks requests to chat.stackoverflow.com?

armujahid commented 5 years ago

Just found that chat.stackoverflow.com is now blocked by our corporate firewall :(

image

Sorry for wasting your time @makyen

makyen commented 5 years ago

Well, that would definitely cause the problem you are seeing. Unfortunately, there isn't anything we can do about that. Your only real options are to get your corporate firewall changed, use a proxy, or use a VPN. The latter two could violate policies at your place of employment, so probably are not a good idea.

If you do use a proxy, it's trivial to set Firefox to use a specific proxy just in one profile.