Page MenuHomePhabricator

CX2: Cannot read property 'shallowCloneFromRange' of null
Closed, ResolvedPublic

Description

While trying to translate infobox of de:Cottbuser_Ostsee to English, we get:

jQuery.Deferred exception: Cannot read property 'shallowCloneFromRange' of null TypeError: Cannot read property 'shallowCloneFromRange' of null
    at VeDmConverter.ve.dm.Converter.getDomFromNode (http://cx2-testing.wmflabs.org/load.php?debug=false&lang=en&modules=ext.visualEditor.core%7Cjquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=1uh2ls1:253:35)
    at VeInitMwCXTarget.ve.init.mw.CXTarget.changeContentSource (<anonymous>:343:465)
    at VeInitMwCXTarget.<anonymous> (<anonymous>:338:809)
    at mightThrow (http://cx2-testing.wmflabs.org/load.php?debug=false&lang=en&modules=ext.visualEditor.core%7Cjquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=1uh2ls1:856:598)
    at process (http://cx2-testing.wmflabs.org/load.php?debug=false&lang=en&modules=ext.visualEditor.core%7Cjquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=vector&version=1uh2ls1:857:269)

CX1 isn't affected.

Event Timeline

Deskana triaged this task as Normal priority.Aug 28 2018, 6:47 PM
Deskana moved this task from To Triage to Up next on the VisualEditor board.
Deskana added a subscriber: Deskana.

Needs comments from Editing engineers to determine what's going on.

Looks like the node you are passing in has become disconnected from the document.

Looks like the node you are passing in has become disconnected from the document.

Yes, when default MT provider fails, we fallback to adapting source and the passed node is of type ve.dm.CXPlaceholderNode, which is detached from the document.


I have tried translating (from German to English) the articles with similar infoboxes to provide more examples where this error is happening and how is rest of the translation process affected.
Similar articles about lakes, de:Klostersee_(Lehnin) and de:Heiliger_See_(Potsdam), as well as article about hill de:Kutschenberg are throwing the same error, which prevents user from translating the infobox. Translation of other sections is not affected.

On the other side, articles with similar infoboxes, de:Sanssouci (about palace) and de:Talsperre_Spremberg (about dam) are not affected by this JS error. Infoboxes of these articles are translatable.

Is there a test server where I can test this?

Is there a test server where I can test this?

You can test here. Just try translating the infobox.

So the problem is you completely replace the node in the first attempt at translation, so by the time it falls through, the node no-longer exists.

You can fix the replaced node by using the same technique you using in the .always block, so in onDocumentActivatePlaceholder:

model.emit( 'beforeTranslation' );
this.MTManager.getPreferredProvider().then( function ( provider ) {
	return this.changeContentSource( model, null, provider );
}.bind( this ) ).fail( function () {
	// If placeholder has been destroyed, look for a section node
	if ( !model ) {
		model = this.getTargetSectionNode( cxid );
	}

however this doesn't fully fix the issue, as the translation fails even with source="source", so the second 'changeContentSource' also fails, and isn't handled. You'll need to add more error handling to leave the document in a sensible state.

Restricted Application added a project: VisualEditor. · View Herald TranscriptSep 19 2018, 4:39 PM

Error Cannot read property 'shallowCloneFromRange' of null, which prevented users from translating infobox of de:Cottbuser_Ostsee to English, no longer happens.

I have tried translating following articles in both cx2-testing and in production. Infoboxes of all articles are translated without any JS errors.

There is saving failure with all these articles, described in T208222.

Etonkovidova closed this task as Resolved.Nov 2 2018, 7:00 PM
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptNov 2 2018, 7:00 PM