Skip to content
Prev Previous commit
Next Next commit
Parsoid: Add fallback for transforms to the proxy
When we are in split mode, we need to account for the transition period
of each domain, during which time some transform requests will actually
need to be handled by Parsoid/JS since the clients retrieved the JS
variant of the HTML. Thefore, for transform end points provide a
fallback in case of a 404 which happens if RESTBase can't retrieve the
stashed content.

Bug: T230791
  • Loading branch information
Marko Obrovac committed Oct 16, 2019
commit cce372e48fcbd1eb91563d4aaf6fe3e3c794d887
16 changes: 16 additions & 0 deletions sys/parsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ class ParsoidProxy {
res.headers = res.headers || {};
res.headers['x-parsoid-variant'] = variant;
return P.resolve(res);
}).catch({ status: 404 }, (e) => {
// if we are in split mode, provide a fallback for
// transforms for the non-default variant
if (this.mode === 'split' && /transform/.test(operation) &&
variant !== this.default_variant) {
if (setHdr) {
req.headers['x-parsoid-variant'] = this.default_variant;
}
return this.mods[this.default_variant][operation](hyper, req)
.then((res) => {
res.headers = res.headers || {};
res.headers['x-parsoid-variant'] = this.default_variant;
return P.resolve(res);
});
}
throw e;
});
}

Expand Down