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

Use deferred for action dispatcher initialization #405

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

tortmayr
Copy link
Contributor

What it does

Fixes a problem in the action dispatcher initialization that was introduced with #402.
Due to the change from async registry provider to direct registry injection it was possible to end up in a dead lock if there was an action handler was registered that listened to the SetModelAction and dispatches a response action.
(This handler would already been triggered during the initialization phase because an empty set model action is dispatched there, the corresponding initializationPromise was not defined at this point -> initialize logic is called again).

Solved by using a proper deferred for the initialization step.

How to test

Should not be required as the change is rather simple and straightforward. However, if needed this can be done by registering a custom action handler in the standalone app:

export default function createContainer(options: IDiagramOptions): Container {
    const parameters = getParameters();
    if (parameters.readonly) {
        options.editMode = EditMode.READONLY;
    }
    const container = createWorkflowDiagramContainer(
        createDiagramOptionsModule(options),
        {
            add: [standaloneTaskEditorModule, accessibilityModule],
            remove: toolPaletteModule
        },
        STANDALONE_MODULE_CONFIG
    );
    bindOrRebind(container, TYPES.ILogger).to(ConsoleLogger).inSingletonScope();
    bindOrRebind(container, TYPES.LogLevel).toConstantValue(LogLevel.warn);
    container.bind(TYPES.IMarqueeBehavior).toConstantValue({ entireEdge: true, entireElement: true });
    if (parameters.inversifyLog) {
        configureInversifyLogger(container);
    }
    configureActionHandler(container, SetModelAction.KIND, TestHandler);
    return container;
}

@injectable()
export class TestHandler implements IActionHandler {
    handle(action: Action): void | Action | ICommand {
        return OptionalAction.mark({ kind: 'test' });
    }
}

Observe that with this handler the application loading fails on master, but still works in this PR.

Follow-ups

Changelog

  • This PR should be mentioned in the changelog
  • This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide)

Copy link
Contributor

@martin-fleck-at martin-fleck-at left a comment

Choose a reason for hiding this comment

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

LGTM!

@tortmayr tortmayr merged commit 7aec575 into master Dec 16, 2024
7 checks passed
@tortmayr tortmayr deleted the action-dispatcher-fix branch December 16, 2024 08:43
holkerveen pushed a commit to holkerveen/glsp-client that referenced this pull request Dec 21, 2024
+Fix eclipse-glsp#401 Node creation  (eclipse-glsp#402)
+ Resolve eclipse-glsp#398 Refactor TypeHints API (eclipse-glsp#399)
+ Resolve eclipse-glsp#396 RouterKind for FeedbackEdge (eclipse-glsp#397)
+ Reuse Sprotty's request/response system and remove custom solution(eclipse-glsp#404)
+ Add support for context menu and harmonize with command palette (eclipse-glsp#405)
holkerveen pushed a commit to holkerveen/glsp-client that referenced this pull request Dec 21, 2024
+Fix eclipse-glsp#401 Node creation  (eclipse-glsp#402)
+ Resolve eclipse-glsp#398 Refactor TypeHints API (eclipse-glsp#399)
+ Resolve eclipse-glsp#396 RouterKind for FeedbackEdge (eclipse-glsp#397)
+ Reuse Sprotty's request/response system and remove custom solution(eclipse-glsp#404)
+ Add support for context menu and harmonize with command palette (eclipse-glsp#405)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants