mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 10:42:44 +00:00
Run patch processing in parallel to prior system to attempt to narrow down not-quite-so-edge cases that did not come up prior to user testing.
This commit is contained in:
@@ -265,7 +265,7 @@ const EditPage = createClass({
|
|||||||
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
||||||
brew.patches = stringifyPatches(makePatches(this.savedBrew.text, brew.text));
|
brew.patches = stringifyPatches(makePatches(this.savedBrew.text, brew.text));
|
||||||
brew.hash = await md5(this.savedBrew.text);
|
brew.hash = await md5(this.savedBrew.text);
|
||||||
brew.text = undefined;
|
//brew.text = undefined; - Temporary parallel path
|
||||||
brew.textBin = undefined;
|
brew.textBin = undefined;
|
||||||
|
|
||||||
const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId);
|
const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId);
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ const api = {
|
|||||||
const brewFromClient = api.excludePropsFromUpdate(req.body);
|
const brewFromClient = api.excludePropsFromUpdate(req.body);
|
||||||
const brewFromServer = req.brew;
|
const brewFromServer = req.brew;
|
||||||
splitTextStyleAndMetadata(brewFromServer);
|
splitTextStyleAndMetadata(brewFromServer);
|
||||||
|
|
||||||
brewFromServer.text = brewFromServer.text.normalize();
|
brewFromServer.text = brewFromServer.text.normalize();
|
||||||
brewFromServer.hash = await md5(brewFromServer.text);
|
brewFromServer.hash = await md5(brewFromServer.text);
|
||||||
|
|
||||||
@@ -357,15 +357,20 @@ const api = {
|
|||||||
let brew = _.assign(brewFromServer, brewFromClient);
|
let brew = _.assign(brewFromServer, brewFromClient);
|
||||||
brew.title = brew.title.trim();
|
brew.title = brew.title.trim();
|
||||||
brew.description = brew.description.trim() || '';
|
brew.description = brew.description.trim() || '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const patches = parsePatch(brewFromClient.patches);
|
const patches = parsePatch(brewFromClient.patches);
|
||||||
brew.text = applyPatches(patches, brewFromServer.text)[0];
|
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
|
||||||
|
const patchedResult = applyPatches(patches, brewFromServer.text)[0];
|
||||||
|
// brew.text = applyPatches(patches, brewFromServer.text)[0];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to apply patches:', {
|
console.error('Failed to apply patches:', {
|
||||||
patches: brewFromClient.patches,
|
patches : brewFromClient.patches,
|
||||||
brewId: brew.editId || 'unknown'
|
brewId : brew.editId || 'unknown',
|
||||||
|
error : err
|
||||||
});
|
});
|
||||||
throw err; // rethrow to preserve the 500 behavior
|
// While running in parallel, don't throw the error upstream.
|
||||||
|
// throw err; // rethrow to preserve the 500 behavior
|
||||||
}
|
}
|
||||||
|
|
||||||
brew.text = api.mergeBrewText(brew);
|
brew.text = api.mergeBrewText(brew);
|
||||||
|
|||||||
Reference in New Issue
Block a user