-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docdiff: investigate why it breaks other integrations #11
Comments
This is probably because doc-diff replaces the DOM at https://github.com/readthedocs/doc-diff/blob/main/src/extension.js#L166 It should probably be loaded last, after all other DOM manipulations are finalized. |
That's why I've tried by putting it as the last item in the I was trying to chain a final ...
return Promise.all(promises);
})
.then(() => {
initializeDocDiff(config);
})
.then(() => {
resolve();
})
.... There |
Hrm... I just realized that all those |
Well, you have three layers of promises so far: the outside promise signalling loading state, the promises for each tool, and the return from return Promise.all(
promises
).then(() => {
return docDiff.initialize(config);
}); Footnotes |
I didn't look closely, but this is generally the issue that makes async code hard. Everything needs to be async to take advantage of async operations. For the purposes of this first iteration, it will be easier to avoid promises/async execution. |
I updated the code to make it a little cleaner and show what I'm trying to do and how I'm chaining the |
It looks like you're not resolving the promises here: https://github.com/readthedocs/readthedocs-client/blob/main/src/index.js#L67-L69 This would leave the Promise waiting for resolve/reject, and your for (let fn of integrations) {
promises.push(
new Promise((resolve) => {
resolve(fn(config));
})
);
}
return new Promise((resolve, reject) => {
...
reject(new Error("Oops!"));
}); Promises tend to have a steep learning curve. Native async code is a bit easier to understand in comparison, as there are lots of ways to shoot your foot with promises. |
![Peek 2023-04-25 16-43](https://user-images.githubusercontent.com/244656/234422680-79c4562a-f2d0-475d-b8a7-a76757ef514b.gif) Closes #62 Closes #23 Closes #11
Docdiff works correctly currently. However, I had to disable it for now because it interferes with other integrations like EthicalAds and Search As You Type.
I assume that it breaks because it changes the DOM and it may be removing some things required for the other integrations? 🤷🏼
The text was updated successfully, but these errors were encountered: