Added debug timing logs for HTML conversion library import+convert (#18912)

refs https://github.com/TryGhost/Product/issues/4086

- we're seeing random test timeouts on CI but not locally, these logs should help pinpoint if it's the require that's taking a long time, the conversion itself, or something else entirely
This commit is contained in:
Kevin Ansfield 2023-11-08 12:26:03 +00:00 committed by GitHub
parent d88934938c
commit 3a975fee18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 2 deletions

View File

@ -133,11 +133,23 @@ module.exports = {
const html = frame.data.pages[0].html;
if (frame.options.source === 'html' && !_.isEmpty(html)) {
if (process.env.CI) {
console.time('htmlToMobiledocConverter (page)'); // eslint-disable-line no-console
}
frame.data.pages[0].mobiledoc = JSON.stringify(mobiledoc.htmlToMobiledocConverter(html));
if (process.env.CI) {
console.timeEnd('htmlToMobiledocConverter (page)'); // eslint-disable-line no-console
}
// normally we don't allow both mobiledoc+lexical but the model layer will remove lexical
// if mobiledoc is already present to avoid migrating formats outside of an explicit conversion
if (process.env.CI) {
console.time('htmlToLexicalConverter (page)'); // eslint-disable-line no-console
}
frame.data.pages[0].lexical = JSON.stringify(lexical.htmlToLexicalConverter(html));
if (process.env.CI) {
console.timeEnd('htmlToLexicalConverter (page)'); // eslint-disable-line no-console
}
}
}

View File

@ -167,11 +167,23 @@ module.exports = {
const html = frame.data.posts[0].html;
if (frame.options.source === 'html' && !_.isEmpty(html)) {
if (process.env.CI) {
console.time('htmlToMobiledocConverter (post)'); // eslint-disable-line no-console
}
frame.data.posts[0].mobiledoc = JSON.stringify(mobiledoc.htmlToMobiledocConverter(html));
if (process.env.CI) {
console.timeEnd('htmlToMobiledocConverter (post)'); // eslint-disable-line no-console
}
// normally we don't allow both mobiledoc+lexical but the model layer will remove lexical
// if mobiledoc is already present to avoid migrating formats outside of an explicit conversion
if (process.env.CI) {
console.time('htmlToLexicalConverter (post)'); // eslint-disable-line no-console
}
frame.data.posts[0].lexical = JSON.stringify(lexical.htmlToLexicalConverter(html));
if (process.env.CI) {
console.timeEnd('htmlToLexicalConverter (post)'); // eslint-disable-line no-console
}
}
}

View File

@ -143,7 +143,17 @@ module.exports = {
get htmlToLexicalConverter() {
try {
return require('@tryghost/kg-html-to-lexical').htmlToLexical;
if (process.env.CI) {
console.time('require @tryghost/kg-html-to-lexical'); // eslint-disable-line no-console
}
const htmlToLexical = require('@tryghost/kg-html-to-lexical').htmlToLexical;
if (process.env.CI) {
console.timeEnd('require @tryghost/kg-html-to-lexical'); // eslint-disable-line no-console
}
return htmlToLexical;
} catch (err) {
throw new errors.InternalServerError({
message: 'Unable to convert from source HTML to Lexical',

View File

@ -75,7 +75,17 @@ module.exports = {
get htmlToMobiledocConverter() {
try {
return require('@tryghost/html-to-mobiledoc').toMobiledoc;
if (process.env.CI) {
console.time('require @tryghost/html-to-mobiledoc'); // eslint-disable-line no-console
}
const toMobiledoc = require('@tryghost/html-to-mobiledoc').toMobiledoc;
if (process.env.CI) {
console.timeEnd('require @tryghost/html-to-mobiledoc'); // eslint-disable-line no-console
}
return toMobiledoc;
} catch (err) {
return () => {
throw new errors.InternalServerError({