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

refactor: Reactivate workflow locking #4770

Merged
merged 13 commits into from
Dec 6, 2022

Conversation

krynble
Copy link
Contributor

@krynble krynble commented Nov 30, 2022

No description provided.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Nov 30, 2022
@@ -206,6 +207,17 @@ export class WorkflowsService {
);
}

// Update the workflow's hash
workflow.hash = uuid();
Copy link
Member

Choose a reason for hiding this comment

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

If we use @BeforeUpdate() to set this in WorkflowEntity, then we ca be certain that this get updated on every update, irrespective of where it comes from in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, but we have another PR to be merged (#4200 ) and it will break if we do so. We'll be updating the workflow_entity on other stuff than only workflow editions, leading to more false positives. For this reason I think it's best to only update the hash when actual changes happen.

@krynble krynble marked this pull request as ready for review December 1, 2022 14:49
Copy link
Contributor

@ivov ivov left a comment

Choose a reason for hiding this comment

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

No issues so far on manual testing.

Two UX questions:

  1. Blocker message is way too long - display duration does not allow to read it in full at normal pace, even when expecting it. And even if we extend duration, blocker message is still probably too long for a simple toast message. Also in the blocker message it would be nice to include a link to open the workflow in a separate tab.
  2. I noticed at /workflows, if a user activates a workflow, a sharee is still able to freely activate/deactivate that same workflow at /workflows, and vice versa. Is this expected? Should they not be blocked?

packages/editor-ui/src/views/NodeView.vue Show resolved Hide resolved
`);

workflowIds.map(({ id }) => {
const [updateQuery, updateParams] = queryRunner.connection.driver.escapeQueryWithParameters(
Copy link
Contributor

Choose a reason for hiding this comment

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

Some UUIDs might need escaping? Or why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No special reason, it's just good practice to send queries through the escape mechanism

Copy link
Member

Choose a reason for hiding this comment

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

doesn't the query-runner do that automatically in the next line?

/**
* Hash of editable workflow state.
*/
@Column({ length: 36 })
Copy link
Contributor

Choose a reason for hiding this comment

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

We are no longer hashing, so versionId instead of hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, changed!

@@ -213,7 +216,7 @@ EEWorkflowController.patch(
'/:id(\\d+)',
ResponseHelper.send(async (req: WorkflowRequest.Update) => {
const { id: workflowId } = req.params;
// const forceSave = req.query.forceSave === 'true'; // disabled temporarily - tests were also disabled
const forceSave = req.query.forceSave === 'true';
Copy link
Contributor

Choose a reason for hiding this comment

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

If you can please unskip and update the relevant tests, and ensure they pass on all three DBs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reminding me this, tests uncommented and fixed.

Copy link
Contributor

@ivov ivov 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 fixing this. Tested manually and on all three DBs. Only two minor comments that should not block merging so approving.

Comment on lines +224 to +228
if (
!forceSave &&
workflow.versionId !== '' &&
workflow.versionId !== shared.workflow.versionId
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Current error message below does not seem relevant anymore?

Since client-side we now have a confirmation modal, should the message in the service here simply state that the attempted change was blocked because of interim updates without force saving?

image

@@ -41,8 +41,8 @@ abstract class ResponseError extends Error {
}

export class BadRequestError extends ResponseError {
constructor(message: string) {
super(message, 400);
constructor(message: string, errorCode?: number) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent confusion, since "error code 100" already means something else:

Suggested change
constructor(message: string, errorCode?: number) {
constructor(message: string, internalErrorCode?: number) {

@krynble krynble merged commit 4813da5 into master Dec 6, 2022
@krynble krynble deleted the n8n-5792-reactivate-workflow-locking branch December 6, 2022 08:25
@krynble krynble added the Upcoming Release Will be part of the upcoming release label Dec 6, 2022
MiloradFilipovic added a commit that referenced this pull request Dec 6, 2022
* master:
  fix: Handle error when workflow does not exist or is inaccessible (#4831)
  feat(editor): Schema view (#4615)
  fix: Enable source-maps on WorkflowRunnerProcess in `own` mode (#4832)
  ci: Fix linting on master (no-changelog) (#4830)
  feat: Add message for readonly nodes. Improve foreign credentials handling (#4759)
  feat(KoBoToolbox Node): Add support for Media file API (#4578)
  fix(Local File Trigger Node): Fix issue that causes a crash if the ignore field is empty (#4824) (#4825)
  refactor: Codex updates for XML and HtmlExtract Nodes (#4801)
  refactor: Reactivate workflow locking (#4770)

# Conflicts:
#	packages/editor-ui/src/Interface.ts
@janober
Copy link
Member

janober commented Dec 7, 2022

Got released with [email protected]

@janober janober removed the Upcoming Release Will be part of the upcoming release label Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants