Skip to content

Commit 36d1d4a

Browse files
author
Marko Obrovac
committed
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
1 parent 14ad601 commit 36d1d4a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sys/parsoid.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,22 @@ class ParsoidProxy {
157157
res.headers = res.headers || {};
158158
res.headers['x-parsoid-variant'] = variant;
159159
return P.resolve(res);
160+
}).catch({ status: 404 }, (e) => {
161+
// if we are in split mode, provide a fallback for
162+
// transforms for the non-default variant
163+
if (this.mode === 'split' && /transform/.test(operation) &&
164+
variant !== this.default_variant) {
165+
if (setHdr) {
166+
req.headers['x-parsoid-variant'] = this.default_variant;
167+
}
168+
return this.mods[this.default_variant][operation](hyper, req)
169+
.then((res) => {
170+
res.headers = res.headers || {};
171+
res.headers['x-parsoid-variant'] = this.default_variant;
172+
return P.resolve(res);
173+
});
174+
}
175+
throw e;
160176
});
161177
}
162178

0 commit comments

Comments
 (0)