@nocobase/plugin-workflow 1.9.61 → 1.9.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,26 +11,26 @@ module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@formily/core": "2.3.0",
13
13
  "@formily/react": "2.3.0",
14
- "@nocobase/client": "1.9.61",
15
- "@nocobase/utils": "1.9.61",
14
+ "@nocobase/client": "1.9.63",
15
+ "@nocobase/utils": "1.9.63",
16
16
  "antd": "5.24.2",
17
17
  "@ant-design/icons": "5.6.1",
18
18
  "react-router-dom": "6.28.1",
19
19
  "react-i18next": "11.18.6",
20
- "lodash": "4.17.23",
20
+ "lodash": "4.18.1",
21
21
  "@dnd-kit/core": "6.1.0",
22
22
  "@formily/shared": "2.3.2",
23
- "@nocobase/plugin-mobile": "1.9.61",
23
+ "@nocobase/plugin-mobile": "1.9.63",
24
24
  "sequelize": "6.35.2",
25
- "@nocobase/server": "1.9.61",
26
- "@nocobase/database": "1.9.61",
27
- "@nocobase/data-source-manager": "1.9.61",
28
- "@nocobase/logger": "1.9.61",
29
- "@nocobase/evaluators": "1.9.61",
25
+ "@nocobase/server": "1.9.63",
26
+ "@nocobase/database": "1.9.63",
27
+ "@nocobase/data-source-manager": "1.9.63",
28
+ "@nocobase/logger": "1.9.63",
29
+ "@nocobase/evaluators": "1.9.63",
30
30
  "@formily/antd-v5": "1.2.3",
31
31
  "@formily/reactive": "2.3.0",
32
- "@nocobase/actions": "1.9.61",
32
+ "@nocobase/actions": "1.9.63",
33
33
  "dayjs": "1.11.13",
34
- "@nocobase/plugin-workflow-test": "1.9.61",
35
- "@nocobase/test": "1.9.61"
34
+ "@nocobase/plugin-workflow-test": "1.9.63",
35
+ "@nocobase/test": "1.9.63"
36
36
  };
@@ -1 +1 @@
1
- {"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2026-04-13T01:31:06.245Z"}
1
+ {"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2026-06-06T13:50:36.500Z"}
@@ -1 +1 @@
1
- {"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2026-04-13T01:31:05.899Z"}
1
+ {"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2026-06-06T13:50:36.163Z"}
@@ -1 +1 @@
1
- {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-04-13T01:31:05.697Z"}
1
+ {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-06-06T13:50:35.971Z"}
@@ -50,6 +50,8 @@ export default class Dispatcher {
50
50
  private prepare;
51
51
  private acquirePendingExecution;
52
52
  private acquireQueueingExecution;
53
+ private acquireWithRetry;
54
+ private isConcurrentAcquireError;
53
55
  private process;
54
56
  }
55
57
  export {};
@@ -33,6 +33,7 @@ var import_crypto = require("crypto");
33
33
  var import_sequelize = require("sequelize");
34
34
  var import_constants = require("./constants");
35
35
  var import_Plugin = require("./Plugin");
36
+ const EXECUTION_ACQUIRE_MAX_ATTEMPTS = 5;
36
37
  class Dispatcher {
37
38
  constructor(plugin) {
38
39
  this.plugin = plugin;
@@ -315,27 +316,38 @@ class Dispatcher {
315
316
  async acquirePendingExecution(execution) {
316
317
  const logger = this.plugin.getLogger(execution.workflowId);
317
318
  const isolationLevel = this.plugin.db.options.dialect === "sqlite" ? [][0] : import_sequelize.Transaction.ISOLATION_LEVELS.REPEATABLE_READ;
318
- let fetched = execution;
319
+ let fetched = null;
319
320
  try {
320
- await this.plugin.db.sequelize.transaction({ isolationLevel }, async (transaction) => {
321
- const ExecutionModelClass = this.plugin.db.getModel("executions");
322
- const [affected] = await ExecutionModelClass.update(
323
- { dispatched: true, status: import_constants.EXECUTION_STATUS.STARTED },
324
- {
325
- where: {
326
- id: execution.id,
327
- dispatched: false
328
- },
329
- transaction
330
- }
331
- );
332
- if (!affected) {
333
- fetched = null;
334
- return;
321
+ await this.acquireWithRetry(
322
+ async () => {
323
+ await this.plugin.db.sequelize.transaction({ isolationLevel }, async (transaction) => {
324
+ const ExecutionModelClass = this.plugin.db.getModel("executions");
325
+ const [affected] = await ExecutionModelClass.update(
326
+ { dispatched: true, status: import_constants.EXECUTION_STATUS.STARTED },
327
+ {
328
+ where: {
329
+ id: execution.id,
330
+ dispatched: false
331
+ },
332
+ transaction
333
+ }
334
+ );
335
+ if (!affected) {
336
+ return;
337
+ }
338
+ await execution.reload({ transaction });
339
+ fetched = execution;
340
+ });
341
+ return false;
342
+ },
343
+ {
344
+ logger,
345
+ conflictMessage: `acquiring pending execution (${execution.id}) conflicted with another worker, retrying`,
346
+ maxAttemptsMessage: `acquiring pending execution (${execution.id}) reached max retry attempts`
335
347
  }
336
- await execution.reload({ transaction });
337
- });
348
+ );
338
349
  } catch (error) {
350
+ fetched = null;
339
351
  logger.error(`acquiring pending execution failed: ${error.message}`, { error });
340
352
  }
341
353
  return fetched;
@@ -344,33 +356,57 @@ class Dispatcher {
344
356
  const isolationLevel = this.plugin.db.options.dialect === "sqlite" ? [][0] : import_sequelize.Transaction.ISOLATION_LEVELS.REPEATABLE_READ;
345
357
  let fetched = null;
346
358
  try {
347
- await this.plugin.db.sequelize.transaction(
348
- {
349
- isolationLevel
350
- },
351
- async (transaction) => {
352
- const execution = await this.plugin.db.getRepository("executions").findOne({
353
- filter: {
354
- dispatched: false,
355
- "workflow.enabled": true
359
+ await this.acquireWithRetry(
360
+ async () => {
361
+ let shouldRetry = false;
362
+ await this.plugin.db.sequelize.transaction(
363
+ {
364
+ isolationLevel
356
365
  },
357
- sort: "id",
358
- transaction
359
- });
360
- if (execution) {
361
- this.plugin.getLogger(execution.workflowId).info(`execution (${execution.id}) fetched from db`);
362
- await execution.update(
363
- {
364
- dispatched: true,
365
- status: import_constants.EXECUTION_STATUS.STARTED
366
- },
367
- { transaction }
368
- );
369
- execution.workflow = this.plugin.enabledCache.get(execution.workflowId);
370
- fetched = execution;
371
- } else {
372
- this.plugin.getLogger("dispatcher").debug(`no execution in db queued to process`);
373
- }
366
+ async (transaction) => {
367
+ const execution = await this.plugin.db.getRepository("executions").findOne({
368
+ filter: {
369
+ dispatched: false,
370
+ "workflow.enabled": true
371
+ },
372
+ sort: "id",
373
+ transaction
374
+ });
375
+ if (!execution) {
376
+ this.plugin.getLogger("dispatcher").debug(`no execution in db queued to process`);
377
+ return;
378
+ }
379
+ const ExecutionModelClass = this.plugin.db.getModel("executions");
380
+ const [affected] = await ExecutionModelClass.update(
381
+ {
382
+ dispatched: true,
383
+ status: import_constants.EXECUTION_STATUS.STARTED
384
+ },
385
+ {
386
+ where: {
387
+ id: execution.id,
388
+ dispatched: false
389
+ },
390
+ transaction
391
+ }
392
+ );
393
+ if (!affected) {
394
+ shouldRetry = true;
395
+ this.plugin.getLogger(execution.workflowId).warn(`execution (${execution.id}) was already acquired by another worker, retrying`);
396
+ return;
397
+ }
398
+ this.plugin.getLogger(execution.workflowId).info(`execution (${execution.id}) fetched from db`);
399
+ await execution.reload({ transaction });
400
+ execution.workflow = this.plugin.enabledCache.get(execution.workflowId);
401
+ fetched = execution;
402
+ }
403
+ );
404
+ return shouldRetry;
405
+ },
406
+ {
407
+ logger: this.plugin.getLogger("dispatcher"),
408
+ conflictMessage: `acquiring execution conflicted with another worker, retrying`,
409
+ maxAttemptsMessage: `acquiring execution reached max retry attempts, will retry on next dispatch`
374
410
  }
375
411
  );
376
412
  } catch (error) {
@@ -378,6 +414,37 @@ class Dispatcher {
378
414
  }
379
415
  return fetched;
380
416
  }
417
+ async acquireWithRetry(acquire, options) {
418
+ for (let attempt = 1; attempt <= EXECUTION_ACQUIRE_MAX_ATTEMPTS; attempt++) {
419
+ let shouldRetry = false;
420
+ try {
421
+ shouldRetry = await acquire();
422
+ } catch (error) {
423
+ if (!this.isConcurrentAcquireError(error)) {
424
+ throw error;
425
+ }
426
+ shouldRetry = true;
427
+ options.logger.warn(options.conflictMessage, { error });
428
+ }
429
+ if (!shouldRetry) {
430
+ break;
431
+ }
432
+ if (attempt >= EXECUTION_ACQUIRE_MAX_ATTEMPTS) {
433
+ options.logger.warn(options.maxAttemptsMessage);
434
+ break;
435
+ }
436
+ }
437
+ }
438
+ isConcurrentAcquireError(error) {
439
+ var _a, _b, _c, _d;
440
+ if (!(error instanceof Error)) {
441
+ return false;
442
+ }
443
+ const databaseError = error;
444
+ const code = ((_a = databaseError.parent) == null ? void 0 : _a.code) || ((_b = databaseError.original) == null ? void 0 : _b.code);
445
+ const errno = ((_c = databaseError.parent) == null ? void 0 : _c.errno) || ((_d = databaseError.original) == null ? void 0 : _d.errno);
446
+ return code === "40001" || code === "40P01" || code === "ER_LOCK_DEADLOCK" || errno === 1205 || errno === 1213;
447
+ }
381
448
  async process(execution, job, options = {}) {
382
449
  var _a, _b;
383
450
  const logger = this.plugin.getLogger(execution.workflowId);
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
7
7
  "description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
8
8
  "description.ru-RU": "Мощный инструмент BPM, обеспечивающий базовую поддержку автоматизации бизнес-процессов с возможностью неограниченного расширения триггеров и узлов.",
9
- "version": "1.9.61",
9
+ "version": "1.9.63",
10
10
  "license": "AGPL-3.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow",
@@ -48,7 +48,7 @@
48
48
  "@nocobase/test": "1.x",
49
49
  "@nocobase/utils": "1.x"
50
50
  },
51
- "gitHead": "e641ea723724099b360c0089956aaefd4d257dd0",
51
+ "gitHead": "dd1ed55ad825b65b3ea7bc0fb7474185b7e21d21",
52
52
  "keywords": [
53
53
  "Workflow"
54
54
  ]