-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
GH-8723: From now on, proxy factories do not wait for reconnect once the websocket connection was disposed #8803
Closed
kittaakos
wants to merge
2
commits into
eclipse-theia:master
from
kittaakos:gh-8723--reject-on-connection-dispose
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
examples/api-samples/src/browser/shell/sample-application-shell.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
import { inject, injectable, interfaces } from 'inversify'; | ||
import { SaveOptions } from '@theia/core/lib/browser/saveable'; | ||
import { MessageService } from '@theia/core/lib/common/message-service'; | ||
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell'; | ||
import { ConnectionStatus, FrontendConnectionStatusService } from '@theia/core/lib/browser/connection-status-service'; | ||
|
||
@injectable() | ||
export class SampleApplicationShell extends ApplicationShell { | ||
|
||
@inject(MessageService) | ||
protected messageService: MessageService; | ||
|
||
@inject(FrontendConnectionStatusService) | ||
protected connectionStatusService: FrontendConnectionStatusService; | ||
|
||
async saveAll(options?: SaveOptions): Promise<void> { | ||
try { | ||
await super.saveAll(options); | ||
} catch (error) { | ||
this.handleError(error); | ||
} | ||
} | ||
|
||
async save(options?: SaveOptions): Promise<void> { | ||
try { | ||
await super.save(options); | ||
} catch (error) { | ||
this.handleError(error); | ||
} | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
private handleError(error: any): void { | ||
const message = this.connectionStatusService.currentStatus === ConnectionStatus.OFFLINE | ||
? 'The backend process is not running. Please copy your unsaved work into your favorite text editor, and restart the IDE.' | ||
: error instanceof Error ? error.message : String(error); | ||
this.messageService.error(`Could not save the changes. ${message}`); | ||
} | ||
|
||
} | ||
|
||
export const bindSampleShell = (bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => { | ||
bind(SampleApplicationShell).toSelf().inSingletonScope(); | ||
rebind(ApplicationShell).toService(SampleApplicationShell); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
it does not throw on purpose to avoid rejecting consequent operations
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.
Thanks for the note. Well, we should reject it somehow. That would be the desired flow when clients want to handle errors. If the error was swallowed on purpose, that's a problem. What was the problematic use-case?
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 can filter the error and rethrow only when it indicates t a connection disposed issue, but the rejection must happen, preferably always.
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.
maybe something like:
but we should also check all clients of
run
that they expect that nowsync
andsave
can throw and can deal with itThere 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.
OK, I will check the call sites. Thanks! Eventually, I am fine with introducing a new template method,
handleError
, withconsole.log(error)
default implementation in themonaco-editor-model.ts
module, but best would be to have the error handling in Theia.