Skip to content

Commit 61c63fd

Browse files
authored
fix: [DHIS2-21855] limit concurrent api requests (#4668)
1 parent 22274a2 commit 61c63fd

5 files changed

Lines changed: 118 additions & 20 deletions

File tree

i18n/en.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ msgstr ""
55
"Content-Type: text/plain; charset=utf-8\n"
66
"Content-Transfer-Encoding: 8bit\n"
77
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
8-
"POT-Creation-Date: 2026-08-07T06:09:06.925Z\n"
9-
"PO-Revision-Date: 2026-08-07T06:09:06.925Z\n"
8+
"POT-Creation-Date: 2026-08-07T10:03:38.581Z\n"
9+
"PO-Revision-Date: 2026-08-07T10:03:38.581Z\n"
1010

1111
msgid "The application could not be loaded."
1212
msgstr "The application could not be loaded."

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"cy:open": "[ \"$IN_DEVCONTAINER\" = \"true\" ] && ./scripts/package/cy-open-devcontainer.sh || ./scripts/package/cy-open-local.sh",
8080
"cy:run": "./scripts/package/cy-run.sh",
8181
"verifyCacheVersion": "node scripts/verifyCacheVersion.js",
82-
"postinstall": "husky && node scripts/createSymlinkToInternalPackages.mjs",
82+
"postinstall": "husky && patch-package && node scripts/createSymlinkToInternalPackages.mjs",
8383
"i18n:add": "d2-app-scripts i18n extract && git add ./i18n/",
8484
"clean": "./scripts/clean.sh && yarn workspaces run clean"
8585
},
@@ -128,6 +128,9 @@
128128
"jsdoc": "^4.0.5",
129129
"jsdoc-babel": "^0.5.0",
130130
"jsdoc-export-default-interop": "^0.3.1",
131+
"p-limit": "^7.3.1",
132+
"patch-package": "^8.0.1",
133+
"postinstall-postinstall": "^2.1.0",
131134
"redux-devtools-extension": "^2.13.9",
132135
"serve": "^14.2.6",
133136
"typescript": "^5.8.2",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
diff --git a/node_modules/@dhis2/data-engine/build/es/links/RestAPILink.js b/node_modules/@dhis2/data-engine/build/es/links/RestAPILink.js
2+
index 07cc7ff..705916c 100644
3+
--- a/node_modules/@dhis2/data-engine/build/es/links/RestAPILink.js
4+
+++ b/node_modules/@dhis2/data-engine/build/es/links/RestAPILink.js
5+
@@ -1,11 +1,13 @@
6+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
8+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9+
+import plimit from 'p-limit';
10+
import { LRUCache } from '../helpers/LRUCache';
11+
import { fetchData } from './RestAPILink/fetchData';
12+
import { joinPath } from './RestAPILink/path';
13+
import { queryToRequestOptions } from './RestAPILink/queryToRequestOptions';
14+
import { queryToResourcePath } from './RestAPILink/queryToResourcePath';
15+
+const limit = plimit(100);
16+
export class RestAPILink {
17+
constructor(config) {
18+
_defineProperty(this, "config", void 0);
19+
@@ -17,7 +19,7 @@ export class RestAPILink {
20+
this.unversionedApiPath = joinPath('api');
21+
}
22+
fetch(path, options) {
23+
- return fetchData(joinPath(this.config.baseUrl, path), options, this);
24+
+ return limit(() => fetchData(joinPath(this.config.baseUrl, path), options, this));
25+
}
26+
executeResourceQuery(type, query, {
27+
signal

src/core_modules/capture-core/components/FormFields/New/Fields/OrgUnitField/OrgUnitTree.component.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,7 @@ type Props = OrgUnitTreeProps & WithStyles<typeof getStyles>;
2828
const OrgUnitTreePlain = (props: Props) => {
2929
const { roots, classes, treeKey, previousOrgUnitId, onSelectClick, selected } = props;
3030
const previousSelectedOrgUnit = usePreviousOrganizationUnit(previousOrgUnitId ?? undefined);
31-
const getExpandedItems = () => {
32-
if (roots && roots.length === 1) {
33-
return [`/${roots[0].id}`];
34-
} else if (roots?.length > 1) {
35-
return roots.map(root => root.path);
36-
}
37-
38-
return undefined;
39-
};
40-
41-
const initiallyExpanded = getExpandedItems();
42-
43-
const [expanded, setExpanded] = React.useState<string[] | undefined>(initiallyExpanded);
31+
const [expanded, setExpanded] = React.useState<string[]>(roots.map(root => root.path));
4432

4533
React.useEffect(() => {
4634
if (previousSelectedOrgUnit?.expandedPaths) {

yarn.lock

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5534,7 +5534,7 @@ ci-info@^2.0.0:
55345534
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
55355535
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==
55365536

5537-
ci-info@^3.2.0:
5537+
ci-info@^3.2.0, ci-info@^3.7.0:
55385538
version "3.9.0"
55395539
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4"
55405540
integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==
@@ -7712,6 +7712,13 @@ find-up@^5.0.0:
77127712
locate-path "^6.0.0"
77137713
path-exists "^4.0.0"
77147714

7715+
find-yarn-workspace-root@^2.0.0:
7716+
version "2.0.0"
7717+
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd"
7718+
integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==
7719+
dependencies:
7720+
micromatch "^4.0.2"
7721+
77157722
flat-cache@^3.0.4:
77167723
version "3.2.0"
77177724
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee"
@@ -9114,7 +9121,7 @@ is-windows@^1.0.1:
91149121
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
91159122
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
91169123

9117-
is-wsl@^2.2.0:
9124+
is-wsl@^2.1.1, is-wsl@^2.2.0:
91189125
version "2.2.0"
91199126
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
91209127
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
@@ -9799,6 +9806,17 @@ json-stable-stringify-without-jsonify@^1.0.1:
97999806
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
98009807
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==
98019808

9809+
json-stable-stringify@^1.0.2:
9810+
version "1.3.0"
9811+
resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.3.0.tgz#8903cfac42ea1a0f97f35d63a4ce0518f0cc6a70"
9812+
integrity sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==
9813+
dependencies:
9814+
call-bind "^1.0.8"
9815+
call-bound "^1.0.4"
9816+
isarray "^2.0.5"
9817+
jsonify "^0.0.1"
9818+
object-keys "^1.1.1"
9819+
98029820
json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
98039821
version "5.0.1"
98049822
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
@@ -9832,6 +9850,11 @@ jsonfile@^6.0.1:
98329850
optionalDependencies:
98339851
graceful-fs "^4.1.6"
98349852

9853+
jsonify@^0.0.1:
9854+
version "0.0.1"
9855+
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.1.tgz#2aa3111dae3d34a0f151c63f3a45d995d9420978"
9856+
integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==
9857+
98359858
jsonparse@^1.2.0:
98369859
version "1.3.1"
98379860
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
@@ -10037,6 +10060,13 @@ kind-of@^6.0.2, kind-of@^6.0.3:
1003710060
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
1003810061
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
1003910062

10063+
klaw-sync@^6.0.0:
10064+
version "6.0.0"
10065+
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
10066+
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
10067+
dependencies:
10068+
graceful-fs "^4.1.11"
10069+
1004010070
klaw@^3.0.0:
1004110071
version "3.0.0"
1004210072
resolved "https://registry.yarnpkg.com/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146"
@@ -10960,7 +10990,7 @@ micromark@^4.0.0:
1096010990
micromark-util-symbol "^2.0.0"
1096110991
micromark-util-types "^2.0.0"
1096210992

10963-
micromatch@^4.0.4, micromatch@^4.0.8:
10993+
micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.8:
1096410994
version "4.0.8"
1096510995
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
1096610996
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
@@ -11378,6 +11408,14 @@ onetime@^5.1.0, onetime@^5.1.2:
1137811408
dependencies:
1137911409
mimic-fn "^2.1.0"
1138011410

11411+
open@^7.4.2:
11412+
version "7.4.2"
11413+
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
11414+
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
11415+
dependencies:
11416+
is-docker "^2.0.0"
11417+
is-wsl "^2.1.1"
11418+
1138111419
optionator@^0.9.1, optionator@^0.9.3:
1138211420
version "0.9.4"
1138311421
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.4.tgz#7ea1c1a5d91d764fb282139c88fe11e182a3a734"
@@ -11440,6 +11478,13 @@ p-limit@^3.0.2:
1144011478
dependencies:
1144111479
yocto-queue "^0.1.0"
1144211480

11481+
p-limit@^7.3.1:
11482+
version "7.3.1"
11483+
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-7.3.1.tgz#ded48cbfa10b161a9928120261fa82c9a282eb3f"
11484+
integrity sha512-0trZaiG7Y7kN/Egy9a8j47t9osC0Tch4PaIWd9yGF6bvmlk7muExRvGNYb8sXBwEKMoNKsbNN9P8EefuQekE4Q==
11485+
dependencies:
11486+
yocto-queue "^1.2.1"
11487+
1144311488
p-locate@^3.0.0:
1144411489
version "3.0.0"
1144511490
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
@@ -11558,6 +11603,26 @@ pascal-case@^3.1.2:
1155811603
no-case "^3.0.4"
1155911604
tslib "^2.0.3"
1156011605

11606+
patch-package@^8.0.1:
11607+
version "8.0.1"
11608+
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-8.0.1.tgz#79d02f953f711e06d1f8949c8a13e5d3d7ba1a60"
11609+
integrity sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==
11610+
dependencies:
11611+
"@yarnpkg/lockfile" "^1.1.0"
11612+
chalk "^4.1.2"
11613+
ci-info "^3.7.0"
11614+
cross-spawn "^7.0.3"
11615+
find-yarn-workspace-root "^2.0.0"
11616+
fs-extra "^10.0.0"
11617+
json-stable-stringify "^1.0.2"
11618+
klaw-sync "^6.0.0"
11619+
minimist "^1.2.6"
11620+
open "^7.4.2"
11621+
semver "^7.5.3"
11622+
slash "^2.0.0"
11623+
tmp "^0.2.4"
11624+
yaml "^2.2.2"
11625+
1156111626
path-dirname@^1.0.0:
1156211627
version "1.0.2"
1156311628
resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
@@ -11780,6 +11845,11 @@ postcss@^8.4.33, postcss@^8.4.38, postcss@^8.4.43, postcss@^8.5.6:
1178011845
picocolors "^1.1.1"
1178111846
source-map-js "^1.2.1"
1178211847

11848+
postinstall-postinstall@^2.1.0:
11849+
version "2.1.0"
11850+
resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
11851+
integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==
11852+
1178311853
prelude-ls@^1.2.1:
1178411854
version "1.2.1"
1178511855
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@@ -13111,6 +13181,11 @@ signal-exit@^4.0.1:
1311113181
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04"
1311213182
integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==
1311313183

13184+
slash@^2.0.0:
13185+
version "2.0.0"
13186+
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
13187+
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==
13188+
1311413189
slash@^3.0.0:
1311513190
version "3.0.0"
1311613191
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
@@ -13924,7 +13999,7 @@ tmp@^0.2.1, tmp@~0.2.1:
1392413999
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.3.tgz#eb783cc22bc1e8bebd0671476d46ea4eb32a79ae"
1392514000
integrity sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==
1392614001

13927-
tmp@^0.2.3:
14002+
tmp@^0.2.3, tmp@^0.2.4:
1392814003
version "0.2.7"
1392914004
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.7.tgz#26f4db11d1601ce8012dcb8a798ece1c06a99059"
1393014005
integrity sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==
@@ -15269,6 +15344,11 @@ yocto-queue@^0.1.0:
1526915344
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
1527015345
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
1527115346

15347+
yocto-queue@^1.2.1:
15348+
version "1.2.2"
15349+
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.2.2.tgz#3e09c95d3f1aa89a58c114c99223edf639152c00"
15350+
integrity sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==
15351+
1527215352
yup@1.2.0:
1527315353
version "1.2.0"
1527415354
resolved "https://registry.yarnpkg.com/yup/-/yup-1.2.0.tgz#9e51af0c63bdfc9be0fdc6c10aa0710899d8aff6"

0 commit comments

Comments
 (0)