Page MenuHomePhabricator

"Uncaught TypeError: Cannot read property '0' of undefined" and VE not loading when repeatedly switching back and forth between read and edit modes
Closed, ResolvedPublic8 Story Points

Description

On any Wikipedia (including SET when "show both editor tabs" is the chosen editing preference), any browser AFAICT (I'm reproducing in Win8):

  1. hit the "Edit" link for a section;
  2. VE loads correctly. Now hit the Back button in the browser;
  3. hit that "Edit" link again;
  4. observe that VE doesn't load (progress bar is complete, but nothing happens).

Console says "Uncaught TypeError: Cannot read property '0' of undefined".
Reported by editors at ja.wiki.

Event Timeline

Elitre created this task.May 16 2016, 2:15 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 16 2016, 2:15 PM

I tried to reproduce this, but the above mentioned steps are not producing the bug. But I have found another set of steps to reproduce the same error:

  1. Make sure in your Preferences section you have "Show me both editor tabs" set.
  2. Now go to Read mode
  3. Click on Edit tab
  4. Go back to Read mode
  5. Now click on the Section Edit link not the Edit tab

Observed Result:
Progress bar stops before it completes, VE does not load. Error in the console:
Uncaught TypeError: Cannot read property '0' of undefined

Ryasmeen triaged this task as High priority.May 27 2016, 5:48 PM
Jdforrester-WMF renamed this task from "Uncaught TypeError: Cannot read property '0' of undefined" and VE not loading to "Uncaught TypeError: Cannot read property '0' of undefined" and VE not loading when repeatedly switching back and forth between read and edit modes.May 31 2016, 7:10 PM
Jdforrester-WMF set the point value for this task to 8.
Jdforrester-WMF moved this task from To Triage to TR0: Interrupt on the VisualEditor board.
AlexMonk-WMF added a subscriber: AlexMonk-WMF.

The original steps worked for me. It seems that we actually start the target loading process twice (causing the loading progress counter to be incremented too much and go into undefined indexes of progressSteps), because onEditSectionLinkClick gets called multiple times - so something is setting that function up as handler again when we close VE (or when we reopen it).

AlexMonk-WMF added a comment.EditedJun 29 2016, 2:34 AM

Looks like it may be this, in DAT.init.js:

deactivate: function () {
	if (
		userPrefPreferShow &&
		( !conf.singleEditTab || tabPreference === 'multi-tab' )
	) {
		init.setupSectionLinks();
	}
}

This setupSectionLinks call used to run on *save* because we replace the page contents, and therefore click handlers need to be set up again. https://gerrit.wikimedia.org/r/#/c/283591/ changed it to run on any deactivation like this. Of course, in this case, the code is getting run without any save and therefore we don't need to set up the click handlers again.

Change 296496 had a related patch set uploaded (by Alex Monk):
Replace section edit click handlers in DAT instead of doing it badly in init

https://gerrit.wikimedia.org/r/296496

Change 296496 merged by jenkins-bot:
Replace section edit click handlers in DAT instead of doing it badly in init

https://gerrit.wikimedia.org/r/296496

Jdforrester-WMF closed this task as Resolved.Jun 29 2016, 12:33 PM
Jdforrester-WMF removed a project: Patch-For-Review.