-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fixed watchdog crash after immediately refreshing application #15981
Conversation
Hm, do I understand correctly that now If so, I don't know if that will not hurt some of our integrators. I remember that in some cases, when using multiple editors, some of our integrators were creating editors in parallel and it sped up total loading time nicely. |
I checked it, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty of pushing small code refactoring that reduces magic a little bit here (it took me a while to get my head around these changes 🙂)
One note, though: The create()
test introduced in this PR is weak
it( 'should create an editor instance after the ongoing destruction process has been finished', async () => { |
diff --git a/packages/ckeditor5-watchdog/src/editorwatchdog.ts b/packages/ckeditor5-watchdog/src/editorwatchdog.ts
index 0919c38968..64f270b3b5 100644
--- a/packages/ckeditor5-watchdog/src/editorwatchdog.ts
+++ b/packages/ckeditor5-watchdog/src/editorwatchdog.ts
@@ -257,7 +257,7 @@ export default class EditorWatchdog<TEditor extends Editor = Editor> extends Wat
config: EditorConfig = this._config!,
context?: Context
): Promise<unknown> {
- this._lifecyclePromise = Promise.resolve( this._lifecyclePromise )
+ this._lifecyclePromise = Promise.resolve()
.then( () => {
super._startErrorHandling();
and this has nothing to do with my refactoring (I checked before and after). Maybe there's a better way to write this test? You could listen to stateChange
and see the #state
and then make some spy call order assertions maybe.
The destroy()
test does its job, though.
On a side note: an integration test in ckeditor5-react would be lovely too. We can rewrite this code in the future and break the business logic for outsiders again and we wouldn't even realize until bug reports start arriving to ckeditor5-react.
@oleq, first of all, I was hoping for comments instead of direct changes. 😞 It would have been better for me and could have sparked some constructive discussion. Remember that you can make changes that might be incorrect, and the author may disagree with them. Anyway, I will respond to your changes:
The first one:
And the second one:
Are you sure that we don't need the benefits arising from the second approach? I'm not entirely convinced, which is why I preferred the previous form.
|
I read your code and I couldn't get it for a while. This was the first time I'd seen anything like it and I realized that you coded it this way because you missed out on an opportunity to pass the ongoing promise to As for your concerns regarding error handling, I verified that const firstPromise = new Promise( () => {
throw new Error( 'first promise error' );
} );
Promise.resolve( firstPromise )
.then( () => {
console.log( 'after first promise' )
} )
.catch( error => {
console.error( 'Error caught:', error.message );
} ); catches errors as well as const firstPromise = new Promise( () => {
throw new Error( 'first promise error' );
} );
Promise.resolve()
.then( () => {
return firstPromise;
} )
.then( () => {
console.log( 'after first promise' )
} )
.catch( error => {
console.error( 'Error caught:', error.message );
} ); We can disagree on the name of the private property. IMO the "current" prefix is very good but "processing" is extremely vague (maybe less vague since we have TS, but still). I'm not attached to my change in this matter, though.
I think we approach PRs differently 🙂 To me any PR (except epics) is a scratchpad and there's nothing wrong with pushing to it. It's a communal effort the moment the code gets public. Sometimes it's easier to make your point this way rather than to write numerous comments and/or paste diffs (or fork branches). You can keep working on top of what I did or revert my commit if you find it unsuitable, that's fine, I don't mind 🙂 |
I would really like to see this merged. We seem to run into this issue when the user is navigating to and from editing sessions using useNavigate() from react router. Despite cutting down on extra renders, its still easy to trigger by loading/unloading multiple docs in quick succession |
@glynam1, we will release it in mid-April. If you still have any issues regarding Watchdog and React integration, let us know. |
Suggested merge commit message (convention)
Fix (watchdog): Watchdog will no longer crash after immediately refreshing the application. Closes #15980.
Additional information
Fixes: ckeditor/ckeditor5-react#370.