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 #2961: a workaround to show output and title of short-lived tasks. #7776

Conversation

a1994846931931
Copy link
Contributor

Signed-off-by: Cai Xuye [email protected]

What it does

How to test

  • Run a task that lives only for a short time, like echo hello, and check the task terminal widget for its title and output;
  • Please also check if the change introduced any new bugs into Theia.
Demo:
  • Before
    short-lived-task-before

  • After
    short-lived-task-after

Review checklist

Reminder for reviewers

widgetOptions: { area: 'bottom' },
mode: widgetOpenMode,
taskInfo
});
Copy link
Contributor Author

@a1994846931931 a1994846931931 May 8, 2020

Choose a reason for hiding this comment

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

The formatting is done by Theia automatically.

@@ -41,10 +41,10 @@ export abstract class BaseTerminalServer implements IBaseTerminalServer {
abstract create(options: IBaseTerminalServerOptions): Promise<number>;

async attach(id: number): Promise<number> {
const term = this.processManager.get(id);
const terminal = this.processManager.get(id);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Align the naming convention in this file.

@@ -997,24 +993,19 @@ export class TaskService implements TaskConfigurationClient {
terminal.sendText(selectedText);
}

async attach(terminalId: number, taskId: number): Promise<void> {
// Get the list of all available running tasks.
const runningTasks: TaskInfo[] = await this.getRunningTasks();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If no corresponding taskInfo is found, the attach function would end up with opening a widget labeled with something like Task: #23 rather than the label of the task, which is ugly.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to provide a workaround for the issue @a1994846931931.
Overall I see there are unnecessary changes and breakage which could be avoided.

I don't think we should mark the issue as fixed since it is only a workaround and the underlying issue is still present.

@@ -177,8 +177,6 @@ export interface TaskIdentifier {
export interface TaskInfo {
/** internal unique task id */
readonly taskId: number,
/** terminal id. Defined if task is run as a terminal process */
readonly terminalId?: number,
Copy link
Member

Choose a reason for hiding this comment

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

Why are we removing the terminalId from the interface.
It is an unnecessary breaking change.

Comment on lines 198 to 201
export interface AttachableTaskInfo extends TaskInfo {
/** terminal id. Defined if task is run as a terminal process */
readonly terminalId: number,
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't see the reason for AttachableTaskInfo, why wasn't TaskInfo sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vince-fugnitto Actually AttachableTaskInfo is not necessary. I'll redo all the changes made to task-protocol.ts.

const runningTasks: TaskInfo[] = await this.getRunningTasks();
// Get the corresponding task information based on task id if available.
const taskInfo: TaskInfo | undefined = runningTasks.find((t: TaskInfo) => t.taskId === taskId);
async attach(taskInfo: AttachableTaskInfo): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change.
If it is necessary it should be included in the CHANGELOG.

@vince-fugnitto vince-fugnitto added the tasks issues related to the task system label May 8, 2020
@a1994846931931 a1994846931931 force-pushed the fix-short-lived-task branch from 6691f88 to 6c0258f Compare May 9, 2020 01:39
@a1994846931931
Copy link
Contributor Author

@vince-fugnitto Hi Fugnitto, thanks for your advice. The AttachableTaskInfo is not necessary. I've updated the code to revert all the changes made to the task-protocol.ts file for a minimum modification.

this.willReapProcesses.set(process.id, process);
setTimeout(() => {
this.willReapProcesses.delete(process.id);
}, this.REAP_TIMEOUT);
Copy link
Contributor

Choose a reason for hiding this comment

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

I did exactly the same thing in my local environment to get around this bug.
I am not sure if this is how it should be fixed. I will leave it to @marechal-p and @akosyakov :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elaihau Haha, what a coincidence. The idea is that if one wants to manipulate, for example, write to that process, or resize the terminal process and so on, the process should be alive, and getAlive may be called (a more reliable way is to get the process by either method, and check its killed property right before manipulating it); otherwise, get method can be used and, although the process may be dead, the caller can still get the output stream or other attached information to that process. The getAlive method is just equivalent to the former get method.

Copy link
Member

Choose a reason for hiding this comment

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

I think the proper solution is to have clear lifecycles and don't rely on timings: #2961 (comment)

@vince-fugnitto
Copy link
Member

@a1994846931931 it's been a while since the pull-request has been updated, do you still plan on working on it?
I believe the comment made by Anton would be the proper solution #2961 (comment) - #7776 (comment).

@vince-fugnitto
Copy link
Member

The issue has been resolved thanks to #9409.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tasks issues related to the task system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output of short-lived tasks is not shown
4 participants