module-linker
module-linker copied to clipboard
Messes with back/forward history navigation
When I'm on GitHub in a source file (history index n) and go back in chrome (n-1), sometimes only the URL bar changes to the previous (n-1) URL but the content stays the same (n), when this extension is installed.
Then I have to reload or go back (n-2) and forward (to n-1) to get to that page (n-1).
This shouldn't happen, please fix it :)
Does that happen even if you don't interact with Module Linker at all (by clicking on links it generates)?
Does that happen even if you don't interact with Module Linker at all (by clicking on links it generates)?
Yes. I have the same issue sometimes.
Yes, when not clicking the module links.
I can't reproduce that, but it is probably being caused by jquery-pjax.
How frequent are these issues? Is it somewhat related to GitHub loading times? When it happens, does GitHub show that blue bar on the top, as if it was loading the page (when you press the back button)?
If there are errors on the console, can you paste them here?
I can't reproduce that
- Open this directory
- Open
application.rbfile - Click on browser
Backbutton - Click on browser
Forwardbutton - Repeat 3 and 4 with different pauses
- If nothing — reload page with directory (1) and try again.
Is it somewhat related to GitHub loading times?
It's related to module-linker re-initialization, I guess.
When it happens, does GitHub show that blue bar on the top, as if it was loading the page (when you press the back button)?
No.
If there are errors on the console, can you paste them here?
No errors.
I've tried it multiple times, alternating pauses, reloading and trying again and again and again. Got nothing. I'm on Firefox, however.
I'm on Firefox, however.
Oh. I'm on Chrome :sweat_smile:
Okay, let's try…
Yeah, I repeated this on the second computer, and on Firefox. With the second or the third attempt, I think.
Look at URL → Page content.

I use Chrome sometimes, on other computers with Module Linker installed, and don't remember seeing that error there too. 😅
Anyway, ok, let me say this: when I said I couldn't reproduce I wasn't doubting you or that the bug existed, I just meant I couldn't see the bug on my computer, so I couldn't debug it or fix it. I was saying basically that I needed help debugging and fixing it.
@fiatjaf OK, thank you.
Now it's stable for me:
Open flame/lib/flame dir (link above), click application.rb, wait for module-linker initialization (these dots near files), press Back, wait 1–2 seconds, press Forward, you'll see module-linker dots again, and they will disappear, wait, they'll appear again, press Back — BOOM, page content isn't changing, but URL is.
Also, you can try to give me some version of extension with debugging output (to console), I think, because now console is really empty.
Oops, there isn't any of that. If you're really into it you might want to download the source code from GitHub, spread out some console.log() and debugger statements, run npm run watch to build, then load it as an unpackaged extension.
But it is ok if you don't want that work. I'll try to find this error again later.
If you're really into it you might want to download the source code from GitHub, spread out some console.log() and debugger statements, run npm run watch to build, then load it as an unpackaged extension.
I offered to make a debug version you, because you know better where in the code there are critical places and which state is better to track.
But it is ok if you don't want that work. I'll try to find this error again later.
And I don't have much free time and skills with JS + npm + Chrome extensions :(
I was able to reproduce.
It's probably related to jquery.pjax, as it is used by GitHub itself, but also by Module Linker (so we can have the same navigation features of GitHub). The way I glued it into the code was somewhat hacky, because it doesn't seem to do what I was expecting it to do (probably my misunderstanding), so I bet the answer lies there.
I need some help here, please.
I need some help here, please.
Does main function can affect to GitHub scripts? I think it's Chrome-extension function and the answer is "no".
Will this bug reproducing without return? Or with always-enabled return? Just clarify: we're needing to complicate the condition or to replace it with another.
The return is there to guarantee we don't run the initialization function twice. But why would this initialization change the URL of the page?
Maybe what's happening is that when we press Back for some reason jquery.pjax fails to load the previous page, but does change the URL. Perhaps the first step to debug it would be to listen for their events.