13

Some toast notifications (i.e. those banners as shown in this screenshot) are not being shown; an error is visible in the console instead.

This bug applies to Meta Stack Overflow and Meta Stack Exchange (possibly others) but not to Stack Overflow (possibly others). The JS sources for these are always a bit different, with the Metas having a more up-to-date version, if I recall correctly.

Case 1

Flag or vote to close a post.

Expected result: the flag dialog closes, you get the familiar “Thanks, we’ll take a look at it” toast notification.

But instead, the flag or close vote dialog doesn’t close, the toast notification does not appear, an error is thrown. The flag or close vote still goes through.

Case 2

Retract the flag or close vote again.

Expected result: the flag dialog closes, you get the familiar “Your vote is retracted” toast notification.

But instead, all the symptoms of Case 1 emerge, and a loading GIF is displayed next to the Retract flag button. The retraction still goes through.


The error is this: “Uncaught TypeError: can’t access property "htmlEncode", this is undefined at stub.en.js:1:37708.

The error occurs inside StackExchange.helpers.showToast, at part of an expression that looks like o.useRawHtml || (e = this.htmlEncode(e)), after it’s called from an obfuscated function in full.en.js: (...t) => e()(...t). e() === StackExchange.helpers.showToast holds true.

It’s a bit difficult to backtrack through the obfuscated code, but it is clear, here, that this.htmlEncode was supposed to refer to StackExchange.helpers.htmlEncode, but the showToast isn’t bound and there’s no way for e()(...t) to be called with any non-undefined this context.

Other instances where this is used inside the StackExchange.helpers object appear to work correctly, and usually StackExchange.helpers is used directly instead of this; that would fix the bug here as well: o.useRawHtml || (e = StackExchange.helpers.htmlEncode(e)) instead of o.useRawHtml || (e = this.htmlEncode(e)).


This is almost certainly related to the JavaScript migration.

I will do some more debugging — almost certainly the problem is more extensive, but this bug report should be enough for Stack Exchange to fix this.

The modals not being dismissed automatically appears to be specific to questions. Inline error pop-ups seem to work correctly. Toast notifications shown when casting or retracting comment flags seem to work correctly. I don’t know if the “Please consider adding a comment if you think this post can be improved.” toast works correctly.

The methods showErrorMessage, showErrorPopup, showInfoMessage, showSuccessMessage, and showBannerMessage all use this.showMessage or this.showErrorMessage. It’s worth checking if these refer to the correct this as well.

3
  • Hooray, this seems to have been fixed, but boo, this seems to have been replaced by a different bug (maybe)! At any rate, I can confirm that the JS has now changed and the bug is no longer reproducible. @JourneymanGeek Feel free to retag this as status-completed. Commented Apr 5, 2022 at 14:12
  • 2
    I think I'll wait till someone who knows what actually was done to retag it :D Commented Apr 5, 2022 at 14:51
  • 1
    FYI, there is a way to get the unobfuscated source code: cdn-dev.sstatic.net/Js/full.en.js. The source for the helper should be in the stub.en.js, though Commented Apr 5, 2022 at 16:57

1 Answer 1

5

These specific messages have been fixed.

close vote or flag vote
initial or retraction
show toast properly

2

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.