Some sequences in the doc can cause the import to hang or crash
See original GitHub issueI had a document containing some fancy spacing characters.
It is hard to really narrow down the issue, i think it was https://codepoints.net/U+202F?lang=en it could also have been https://codepoints.net/U+200A?lang=en i have seen both during my debugging session and i suppose intense copying and pasting between google docs, onenote and various text editors probably transforms these along the way…
At the moment i cannot get the plugin to hang any more, but instead crash, see this at the end of my message.
When the plugin tries to fetch this document, it just hangs on
⠼ source-google-docs — fetching
(the little dots on the left stop moving)
I have narrowed it down to this part of the code in utils/google-docs.js:
const googleDocuments = await Promise.all(
documentsProperties.map(async (properties) => {
const document = await fetchDocument(properties.id)
//console.log("document is : " + JSON.stringify(document, null, 4))
const googleDocument = new GoogleDocument({
document,
properties,
options,
links,
})
console.log("this doc was fetched : " + properties.path)
if (process.env.NODE_ENV === "DOCS_TO_TESTS") {
writeDocumentToTests(googleDocument)
}
return googleDocument
})
)
Note the extra console.log. This allowed me to track down the route cause in a very DIY way, first seeing which doc was the one never being fetched and letting the process hang, then removing parts of the doc until i figured the offending one.
Now making further experiments with this sequence, sometimes the import does not hang but instead crashes with the following error:
source-google-docs: Cannot read property '1' of null
TypeError: Cannot read property '1' of null
- google-document.js:55 GoogleDocument.formatText
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-document.js:55:32
- google-document.js:354
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-document.js:354:27
- Array.forEach
- google-document.js:320 GoogleDocument.processParagraph
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-document.js:320:24
- google-document.js:541
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-document.js:541:16
- Array.forEach
- google-document.js:515 GoogleDocument.process
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-document.js:515:32
- google-document.js:30 new GoogleDocument
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-document.js:30:10
- google-docs.js:41
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-docs.js:41:30
- task_queues:93 processTicksAndRejections
node:internal/process/task_queues:93:5
- async Promise.all
- google-docs.js:37 fetchDocuments
[withPigeonMaps]/[gatsby-source-google-docs]/utils/google-docs.js:37:27
- source-nodes.js:33 Object.exports.sourceNodes
[withPigeonMaps]/[gatsby-source-google-docs]/utils/source-nodes.js:33:29
- api-runner-node.js:434 runAPI
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Great! Thank you
I just tested and the document was imported and generated a page with no issue. Thanks!
I will delete the google doc from my google drive after the issue is closed.