Skip to content
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

fix: Update UI if custom errorHandler #17504

Merged
merged 3 commits into from
Sep 1, 2023

Conversation

caalador
Copy link
Contributor

@caalador caalador commented Aug 28, 2023

Enable update of UI for beforeClientResponse
execution throwing an exception when a
custom ErrorHandler is set.

Fixes #17352

Enable update of UI for
beforeClientResponse
execution when a custom
ErrorHandler is set.

Fixes #17352
@github-actions
Copy link

github-actions bot commented Aug 28, 2023

Test Results

1 004 files  ±0  1 004 suites  ±0   1h 3m 22s ⏱️ - 2m 47s
6 394 tests +1  6 353 ✔️ +1  41 💤 ±0  0 ±0 
6 650 runs  +4  6 602 ✔️ +4  48 💤 ±0  0 ±0 

Results for commit dd43a73. ± Comparison against base commit 74196a0.

♻️ This comment has been updated with latest results.

@mshabarov mshabarov self-requested a review August 28, 2023 11:00
@caalador caalador marked this pull request as ready for review August 29, 2023 09:43
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@mshabarov mshabarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that I understand why vaadinSession.getErrorHandler().error(new ErrorEvent(t)); isn't called or doesn't apply UI error-related custom changes when before client reponse callback throws.

When the exception occurs in the callback, it arises from writeUidl to the handleExceptionDuringRequest.

How it makes difference where the exception is thrown, because UIDL write is interrupted anyway if it happens a bit before or later than before client response callbacks handling?

I assume that besides runExecutionsBeforeClientResponse method we have few other places where exceptions potentially can happen that also would break the UIDL writing.

Will do more code digging.

@caalador
Copy link
Contributor Author

caalador commented Sep 1, 2023

So the normal UIDL request is handled in ServerRpcHandler before write and normal exceptions happen during the invocation handling. UidlRequestHandler::l114 -> ServerRpcHandler::l323 -> ServerRpcHandler::l440 -> ServerRpcHandler::handleInvocationData here you can see that it is handled inside a try catch block that calls the errorHandler and continues execution.
Then when the project throws during the writeUidl when executing beforeClientResponses we will fall all the way up to VaadinService::handleRequest and execute VaadinService::handleExceptionDuringRequest that will run the error handler, but only send the internal error back to the client.

Copy link
Contributor

@mshabarov mshabarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @caalador for explanations, now I think I got it. Looks good to me. Seems like there is nothing else called in writeUidl that might have a user code. JS invocations maybe, but they are not executed on the server anyway.

@mshabarov mshabarov merged commit c5a0420 into main Sep 1, 2023
@mshabarov mshabarov deleted the issues/17352-beforeClientResponse branch September 1, 2023 06:21
vaadin-bot pushed a commit that referenced this pull request Sep 1, 2023
Enable update of UI for
beforeClientResponse
execution when a custom
ErrorHandler is set.

Fixes #17352

Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
vaadin-bot pushed a commit that referenced this pull request Sep 1, 2023
Enable update of UI for
beforeClientResponse
execution when a custom
ErrorHandler is set.

Fixes #17352

Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
vaadin-bot pushed a commit that referenced this pull request Sep 1, 2023
Enable update of UI for
beforeClientResponse
execution when a custom
ErrorHandler is set.

Fixes #17352

Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
vaadin-bot added a commit that referenced this pull request Sep 1, 2023
Enable update of UI for
beforeClientResponse
execution when a custom
ErrorHandler is set.

Fixes #17352

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
vaadin-bot added a commit that referenced this pull request Sep 1, 2023
Enable update of UI for
beforeClientResponse
execution when a custom
ErrorHandler is set.

Fixes #17352

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
vaadin-bot added a commit that referenced this pull request Sep 1, 2023
Enable update of UI for
beforeClientResponse
execution when a custom
ErrorHandler is set.

Fixes #17352

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
@tomivirkki
Copy link
Member

I wonder if this caused some breaking change? After this was merged, certain EditorImplTest unit tests in flow-components started failing.

@caalador
Copy link
Contributor Author

caalador commented Sep 4, 2023

Nothing should change if there is no custom ErrorHandler set.
It would seem spreadsheet, upload and grid add one for on attach, so that would make it not show internal error on the client side and no throw as the handler should handle that. I guess its editorIsInBufferedMode_closeEditorThrows that fails?

@tomivirkki
Copy link
Member

tomivirkki commented Sep 4, 2023

It's actually those tests that have @Test(expected = IllegalStateException.class):

java.lang.Exception: Unexpected exception, expected[java.lang.IllegalStateException] but was[java.lang.NullPointerException]
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because the return value of "com.vaadin.flow.server.VaadinSession.getErrorHandler()" is null

@caalador
Copy link
Contributor Author

caalador commented Sep 4, 2023

Ok. That's an interesting state, I'll add a null handler test and look into it.

@caalador
Copy link
Contributor Author

caalador commented Sep 4, 2023

Seems the underlying issue is the mock session that returns a null ErrorHandler at which it fails. Fix incoming.

@caalador
Copy link
Contributor Author

caalador commented Sep 4, 2023

#17542

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.2.0.alpha10 and is also targeting the upcoming stable 24.2.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done - pending release
Development

Successfully merging this pull request may close these issues.

Custom ErrorHandler implementation's UI changes are ignored
5 participants