Problem with DiscoTOC: TypeError: _offsetCalculator.headerOffset is not a function

Dear Discourse team, Dear @Johani,

thanks a stack for the excellent Discourse addon DiscoTOC - automatic table of contents.

Yesterday, a user reported that the TOC navigation stopped working on community.hiveeyes.org, an example can be found at [1]. The instance is running Discourse 2.8.0.beta10 and the latest DiscoTOC, upgraded from within the theme component manager.

On two other Discourse instances, everything seems to be fine:

  • 2.8.0.beta10 (self-hosted), DiscoTOC 17 commits behind, on 5b051e18 [2]
  • 2.9.0.beta2 (business plan), DiscoTOC 1 commit behind, on 9933031 [3]

Do you think the reason might be any of the other plugins we installed on the system [4]? We never experienced any kinds of similar problems with DiscoTOC until now.

Thank you in advance for taking the time to look into this. We are inclined to believe it will be something silly on our end, because we haven’t been able to discover any similar reports from others yet. On another perspective, the outcome here might help others observing similar things as well.

With kind regards,
Andreas.


The error in Firefox’ browser console is Uncaught TypeError: _offsetCalculator.headerOffset is not a function in function updateTOCSidebar.



  1. Installation von Saraswati auf SBC-Systemen (Debian), mit Upload per rsync oder FTP - BOB-Anleitungen - Hiveeyes ↩︎

  2. Panodata Map Panel for Grafana - The workbench - Panodata Community ↩︎

  3. Interpolation of missing time-series values - Tutorials - CrateDB Community ↩︎

  4. Installed plugins.

    ↩︎
1 Like

The plugin footnote is a little tricky to read on mobile. I’ll just pop a list here too, so it’s more visible. :+1: (nothing jumps out at me as an obvious conflict though, but someone else may spot something)

Installed Plugins:

1 Like

Hi again,

when following the reference to updateTOCSidebar:210, Firefox shows this code

210: var distance = Math.abs(_domUtils.default.offset(heading).top - (0, _offsetCalculator.headerOffset)() - window.scrollY);

with an indicator that there might be a syntax error

while the original code is

Do you think there is a remote possibility this might be teething problems with REFACTOR: General component overhaul by pmusaraj · Pull Request #19 · discourse/DiscoTOC · GitHub, @pmusaraj?

This can be inspected on our public Discourse instance, for example on the page Installation von Saraswati auf SBC-Systemen (Debian), mit Upload per rsync oder FTP - BOB-Anleitungen - Hiveeyes.

With kind regards,
Andreas.

/cc @eviltrout, @CvX, @joffreyjaffeux

1 Like

I think headerOffset, used by DiscoTOC since the 18 jan refactoring, appears in app/assets/javascripts/discourse/app/lib/offset-calculator.js in this commit on 7 jan, between 2.8.0.beta10 (21 dec) and 2.8.0.beta11 (13 jan)

2 Likes

So we should either upgrade Discourse or downgrade DiscoTOC to a version before the refactoring, right? Thank you!

1 Like

Yes.

One thing you should always do before reporting a bug is trying to see if it is still there on latest {tests-passed|stable} .

5 Likes

Sure thing, thanks a stack!

But I also have another perspective about reporting stuff I would like to share in this context: To feed search engines in order to give others observing the same error a guideline how to handle and mitigate the issue.

Like: Hey, what’s going on here? »Uncaught TypeError« on the browser console? Let me paste this into the search box right away. Ah, right, here we go – I see, just upgrade Discourse or downgrade DiscoTOC. Thanks, bye.


Thank you very much for your quick support, Richard! Appreciate it.

Hi again,

we just wanted to report back that after upgrading to Discourse 2.9.0.beta2, everything is in order again.

Thank you very much and with kind regards,
Andreas.

2 Likes