From 8d76966d999a6a75c9a8f3125e5b9a86b1e7d803 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 15 Apr 2024 21:14:31 +0530 Subject: [PATCH 1/8] Upgrade Electron and other dependencies This was primarily for getting the latest Electron, but I ran `yarn upgrade-interactive` and upgraded the other non-breaking deps (mostly dev) too. Reason for wanting electron is to try and see if this backport fixes the issue with our streams not getting faithfully written: https://github.com/electron/electron/pull/41052 In some ad-hoc and quick testing, I noticed that the new `writeStream` we've implemented works fine for files up to 128 K, presumably some chunk size, but then begins to diverge. Sounds similar (but not exactly the same) as this issue: https://github.com/electron/electron/issues/39658 Unfortunately, this didn't fix the issue we're facing, so our case is perhaps different. --- desktop/package.json | 4 +- desktop/yarn.lock | 192 ++++++++++++++++++++++--------------------- 2 files changed, 102 insertions(+), 94 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index 032953d8d0..69d54f75be 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -44,8 +44,8 @@ "electron-builder-notarize": "^1.5", "eslint": "^8", "prettier": "^3", - "prettier-plugin-organize-imports": "^3.2", - "prettier-plugin-packagejson": "^2.4", + "prettier-plugin-organize-imports": "^3", + "prettier-plugin-packagejson": "^2", "shx": "^0.3", "typescript": "^5" }, diff --git a/desktop/yarn.lock b/desktop/yarn.lock index a4cc12cfe4..a5b86f1eb3 100644 --- a/desktop/yarn.lock +++ b/desktop/yarn.lock @@ -125,7 +125,7 @@ dependencies: eslint-visitor-keys "^3.3.0" -"@eslint-community/regexpp@^4.5.1", "@eslint-community/regexpp@^4.6.1": +"@eslint-community/regexpp@^4.10.0", "@eslint-community/regexpp@^4.6.1": version "4.10.0" resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== @@ -285,7 +285,7 @@ resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4" integrity sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA== -"@types/json-schema@^7.0.12": +"@types/json-schema@^7.0.15": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== @@ -303,9 +303,9 @@ integrity sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g== "@types/node@*", "@types/node@^20.9.0": - version "20.11.30" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.30.tgz#9c33467fc23167a347e73834f788f4b9f399d66f" - integrity sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw== + version "20.12.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.7.tgz#04080362fa3dd6c5822061aa3124f5c152cff384" + integrity sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg== dependencies: undici-types "~5.26.4" @@ -334,7 +334,7 @@ dependencies: "@types/node" "*" -"@types/semver@^7.5.0": +"@types/semver@^7.5.8": version "7.5.8" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e" integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ== @@ -352,90 +352,90 @@ "@types/node" "*" "@typescript-eslint/eslint-plugin@^7": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz#de61c3083842fc6ac889d2fc83c9a96b55ab8328" - integrity sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw== + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.6.0.tgz#1f5df5cda490a0bcb6fbdd3382e19f1241024242" + integrity sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A== dependencies: - "@eslint-community/regexpp" "^4.5.1" - "@typescript-eslint/scope-manager" "7.4.0" - "@typescript-eslint/type-utils" "7.4.0" - "@typescript-eslint/utils" "7.4.0" - "@typescript-eslint/visitor-keys" "7.4.0" + "@eslint-community/regexpp" "^4.10.0" + "@typescript-eslint/scope-manager" "7.6.0" + "@typescript-eslint/type-utils" "7.6.0" + "@typescript-eslint/utils" "7.6.0" + "@typescript-eslint/visitor-keys" "7.6.0" debug "^4.3.4" graphemer "^1.4.0" - ignore "^5.2.4" + ignore "^5.3.1" natural-compare "^1.4.0" - semver "^7.5.4" - ts-api-utils "^1.0.1" + semver "^7.6.0" + ts-api-utils "^1.3.0" "@typescript-eslint/parser@^7": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.4.0.tgz#540f4321de1e52b886c0fa68628af1459954c1f1" - integrity sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ== + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.6.0.tgz#0aca5de3045d68b36e88903d15addaf13d040a95" + integrity sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg== dependencies: - "@typescript-eslint/scope-manager" "7.4.0" - "@typescript-eslint/types" "7.4.0" - "@typescript-eslint/typescript-estree" "7.4.0" - "@typescript-eslint/visitor-keys" "7.4.0" + "@typescript-eslint/scope-manager" "7.6.0" + "@typescript-eslint/types" "7.6.0" + "@typescript-eslint/typescript-estree" "7.6.0" + "@typescript-eslint/visitor-keys" "7.6.0" debug "^4.3.4" -"@typescript-eslint/scope-manager@7.4.0": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz#acfc69261f10ece7bf7ece1734f1713392c3655f" - integrity sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw== +"@typescript-eslint/scope-manager@7.6.0": + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.6.0.tgz#1e9972f654210bd7500b31feadb61a233f5b5e9d" + integrity sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w== dependencies: - "@typescript-eslint/types" "7.4.0" - "@typescript-eslint/visitor-keys" "7.4.0" + "@typescript-eslint/types" "7.6.0" + "@typescript-eslint/visitor-keys" "7.6.0" -"@typescript-eslint/type-utils@7.4.0": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz#cfcaab21bcca441c57da5d3a1153555e39028cbd" - integrity sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw== +"@typescript-eslint/type-utils@7.6.0": + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.6.0.tgz#644f75075f379827d25fe0713e252ccd4e4a428c" + integrity sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw== dependencies: - "@typescript-eslint/typescript-estree" "7.4.0" - "@typescript-eslint/utils" "7.4.0" + "@typescript-eslint/typescript-estree" "7.6.0" + "@typescript-eslint/utils" "7.6.0" debug "^4.3.4" - ts-api-utils "^1.0.1" + ts-api-utils "^1.3.0" -"@typescript-eslint/types@7.4.0": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.4.0.tgz#ee9dafa75c99eaee49de6dcc9348b45d354419b6" - integrity sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw== +"@typescript-eslint/types@7.6.0": + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.6.0.tgz#53dba7c30c87e5f10a731054266dd905f1fbae38" + integrity sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ== -"@typescript-eslint/typescript-estree@7.4.0": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz#12dbcb4624d952f72c10a9f4431284fca24624f4" - integrity sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg== +"@typescript-eslint/typescript-estree@7.6.0": + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.6.0.tgz#112a3775563799fd3f011890ac8322f80830ac17" + integrity sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw== dependencies: - "@typescript-eslint/types" "7.4.0" - "@typescript-eslint/visitor-keys" "7.4.0" + "@typescript-eslint/types" "7.6.0" + "@typescript-eslint/visitor-keys" "7.6.0" debug "^4.3.4" globby "^11.1.0" is-glob "^4.0.3" - minimatch "9.0.3" - semver "^7.5.4" - ts-api-utils "^1.0.1" + minimatch "^9.0.4" + semver "^7.6.0" + ts-api-utils "^1.3.0" -"@typescript-eslint/utils@7.4.0": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.4.0.tgz#d889a0630cab88bddedaf7c845c64a00576257bd" - integrity sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg== +"@typescript-eslint/utils@7.6.0": + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.6.0.tgz#e400d782280b6f724c8a1204269d984c79202282" + integrity sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA== dependencies: "@eslint-community/eslint-utils" "^4.4.0" - "@types/json-schema" "^7.0.12" - "@types/semver" "^7.5.0" - "@typescript-eslint/scope-manager" "7.4.0" - "@typescript-eslint/types" "7.4.0" - "@typescript-eslint/typescript-estree" "7.4.0" - semver "^7.5.4" + "@types/json-schema" "^7.0.15" + "@types/semver" "^7.5.8" + "@typescript-eslint/scope-manager" "7.6.0" + "@typescript-eslint/types" "7.6.0" + "@typescript-eslint/typescript-estree" "7.6.0" + semver "^7.6.0" -"@typescript-eslint/visitor-keys@7.4.0": - version "7.4.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz#0c8ff2c1f8a6fe8d7d1a57ebbd4a638e86a60a94" - integrity sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA== +"@typescript-eslint/visitor-keys@7.6.0": + version "7.6.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.6.0.tgz#d1ce13145844379021e1f9bd102c1d78946f4e76" + integrity sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw== dependencies: - "@typescript-eslint/types" "7.4.0" - eslint-visitor-keys "^3.4.1" + "@typescript-eslint/types" "7.6.0" + eslint-visitor-keys "^3.4.3" "@ungap/structured-clone@^1.2.0": version "1.2.0" @@ -1140,9 +1140,9 @@ ejs@^3.1.8: jake "^10.8.5" electron-builder-notarize@^1.5: - version "1.5.1" - resolved "https://registry.yarnpkg.com/electron-builder-notarize/-/electron-builder-notarize-1.5.1.tgz#e00b868a67ef20a77f00017606626f24fdbdc445" - integrity sha512-xS7s9gE+1AcJIuJ4DU/LqCrmRypE1zOR/6b66egKzgP/UVh9YSa7rINos34gF/KcueNDQU39HcXcCEKiEI5wPQ== + version "1.5.2" + resolved "https://registry.yarnpkg.com/electron-builder-notarize/-/electron-builder-notarize-1.5.2.tgz#540185b57a336fc6eec01bfe092a3b4764459255" + integrity sha512-vo6RGgIFYxMk2yp59N4NsvmAYfB7ncYi6gV9Fcq2TVKxEn2tPXrSjIKB2e/pu+5iXIY6BHNZNXa75F3DHgOOLA== dependencies: dotenv "^8.2.0" electron-notarize "^1.1.1" @@ -1215,9 +1215,9 @@ electron-updater@^6.1: tiny-typed-emitter "^2.1.0" electron@^29: - version "29.1.5" - resolved "https://registry.yarnpkg.com/electron/-/electron-29.1.5.tgz#b745b4d201c1ac9f84d6aa034126288dde34d5a1" - integrity sha512-1uWGRw/ffA62lcrklxGUgVxVtOHojsg/nwsYr+/F9cVjipZJn8iPv/ABGIIexhmUqWcho8BqfTJ4osCBa29gBg== + version "29.3.0" + resolved "https://registry.yarnpkg.com/electron/-/electron-29.3.0.tgz#8e65cb08e9c0952c66d3196e1b5c811c43b8c5b0" + integrity sha512-ZxFKm0/v48GSoBuO3DdnMlCYXefEUKUHLMsKxyXY4nZGgzbBKpF/X8haZa2paNj23CLfsCKBOtfc2vsEQiOOsA== dependencies: "@electron/get" "^2.0.0" "@types/node" "^20.9.0" @@ -1835,7 +1835,7 @@ ieee754@^1.1.13: resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== -ignore@^5.2.0, ignore@^5.2.4: +ignore@^5.2.0, ignore@^5.2.4, ignore@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw== @@ -2190,13 +2190,6 @@ mimic-response@^3.1.0: resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== -minimatch@9.0.3, minimatch@^9.0.1: - version "9.0.3" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" - integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== - dependencies: - brace-expansion "^2.0.1" - minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -2211,6 +2204,20 @@ minimatch@^5.0.1, minimatch@^5.1.1: dependencies: brace-expansion "^2.0.1" +minimatch@^9.0.1: + version "9.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" + integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^9.0.4: + version "9.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" + integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.2.3, minimist@^1.2.6: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" @@ -2482,17 +2489,17 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier-plugin-organize-imports@^3.2: +prettier-plugin-organize-imports@^3: version "3.2.4" resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.4.tgz#77967f69d335e9c8e6e5d224074609309c62845e" integrity sha512-6m8WBhIp0dfwu0SkgfOxJqh+HpdyfqSSLfKKRZSFbDuEQXDDndb8fTpRWkUrX/uBenkex3MgnVk0J3b3Y5byog== -prettier-plugin-packagejson@^2.4: - version "2.4.12" - resolved "https://registry.yarnpkg.com/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.4.12.tgz#eeb917dad83ae42d0caccc9f26d3728b5c4f2434" - integrity sha512-hifuuOgw5rHHTdouw9VrhT8+Nd7UwxtL1qco8dUfd4XUFQL6ia3xyjSxhPQTsGnSYFraTWy5Omb+MZm/OWDTpQ== +prettier-plugin-packagejson@^2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.5.0.tgz#23d2cb8b1f7840702d35e3a5078e564ea0bc63e0" + integrity sha512-6XkH3rpin5QEQodBSVNg+rBo4r91g/1mCaRwS1YGdQJZ6jwqrg2UchBsIG9tpS1yK1kNBvOt84OILsX8uHzBGg== dependencies: - sort-package-json "2.8.0" + sort-package-json "2.10.0" synckit "0.9.0" prettier@^3: @@ -2711,7 +2718,7 @@ semver@^6.2.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -semver@^7.3.2, semver@^7.3.5, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4: +semver@^7.3.2, semver@^7.3.5, semver@^7.3.8, semver@^7.5.3, semver@^7.6.0: version "7.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== @@ -2800,10 +2807,10 @@ sort-object-keys@^1.1.3: resolved "https://registry.yarnpkg.com/sort-object-keys/-/sort-object-keys-1.1.3.tgz#bff833fe85cab147b34742e45863453c1e190b45" integrity sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg== -sort-package-json@2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-2.8.0.tgz#6a46439ad0fef77f091e678e103f03ecbea575c8" - integrity sha512-PxeNg93bTJWmDGnu0HADDucoxfFiKkIr73Kv85EBThlI1YQPdc0XovBgg2llD0iABZbu2SlKo8ntGmOP9wOj/g== +sort-package-json@2.10.0: + version "2.10.0" + resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-2.10.0.tgz#6be07424bf3b7db9fbb1bdd69e7945f301026d8a" + integrity sha512-MYecfvObMwJjjJskhxYfuOADkXp1ZMMnCFC8yhp+9HDsk7HhR336hd7eiBs96lTXfiqmUNI+WQCeCMRBhl251g== dependencies: detect-indent "^7.0.1" detect-newline "^4.0.0" @@ -2811,6 +2818,7 @@ sort-package-json@2.8.0: git-hooks-list "^3.0.0" globby "^13.1.2" is-plain-obj "^4.1.0" + semver "^7.6.0" sort-object-keys "^1.1.3" source-map-support@^0.5.19: @@ -3018,7 +3026,7 @@ truncate-utf8-bytes@^1.0.0: dependencies: utf8-byte-length "^1.0.1" -ts-api-utils@^1.0.1: +ts-api-utils@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1" integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ== From a5be903abe229616887e84c8af82530e3d303e30 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 15 Apr 2024 21:37:38 +0530 Subject: [PATCH 2/8] Try writing the stream manually (same result) --- desktop/src/main/stream.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/desktop/src/main/stream.ts b/desktop/src/main/stream.ts index 8ddb80dc6a..2d0eaa62c0 100644 --- a/desktop/src/main/stream.ts +++ b/desktop/src/main/stream.ts @@ -37,7 +37,16 @@ export const registerStreamProtocol = () => { /* host-pathname----- */ case "write": try { - await writeStream(path, request.body); + // await writeStream(path, request.body); + console.log("starting stream"); + let c = 0; + for await (const p of request.body as any) { + if (c == 327680) console.log(p); + fs.appendFile(path, p); + c += p.length; + } + console.log("ending stream"); + return new Response("", { status: 200 }); } catch (e) { log.error(`Failed to write stream for ${url}`, e); From 2577cfe2f10e523a63a7efb3a8824acce7b9c750 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 15 Apr 2024 21:43:38 +0530 Subject: [PATCH 3/8] Replace cast with @ts-expect-error --- web/apps/photos/src/utils/native-stream.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts index 809aa9e209..65db237b30 100644 --- a/web/apps/photos/src/utils/native-stream.ts +++ b/web/apps/photos/src/utils/native-stream.ts @@ -21,16 +21,15 @@ export const writeStream = async (path: string, stream: ReadableStream) => { // only within our desktop (Electron) app, Chromium, don't support 'full' // duplex mode (i.e. streaming both the request and the response). // https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests - // - // In another twist, the TypeScript libdom.d.ts does not include the - // "duplex" parameter, so we need to cast to get TypeScript to let this code - // through. e.g. see https://github.com/node-fetch/node-fetch/issues/1769 const req = new Request(`stream://write${path}`, { // GET can't have a body method: "POST", body: stream, + // @ts-expect-error TypeScript's libdom.d.ts does not include the + // "duplex" parameter, e.g. see + // https://github.com/node-fetch/node-fetch/issues/1769. duplex: "half", - } as unknown as RequestInit); + }); const res = await fetch(req); if (!res.ok) throw new Error( From 1e202a76c437714c18b05de512718b775b3cd55a Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 16 Apr 2024 09:39:43 +0530 Subject: [PATCH 4/8] Works if we don't stream --- web/apps/photos/src/utils/native-stream.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts index 65db237b30..12b55f68b1 100644 --- a/web/apps/photos/src/utils/native-stream.ts +++ b/web/apps/photos/src/utils/native-stream.ts @@ -15,6 +15,11 @@ * @param stream The stream which should be written into the file. * */ export const writeStream = async (path: string, stream: ReadableStream) => { + + const response = new Response(stream); + const blob = await response.blob(); + // const ReadableStream() + // The duplex parameter needs to be set to 'half' when streaming requests. // // Currently browsers, and specifically in our case, since this code runs @@ -24,11 +29,11 @@ export const writeStream = async (path: string, stream: ReadableStream) => { const req = new Request(`stream://write${path}`, { // GET can't have a body method: "POST", - body: stream, - // @ts-expect-error TypeScript's libdom.d.ts does not include the + body: blob, + // @ts-expect-erroXXX TypeScript's libdom.d.ts does not include the // "duplex" parameter, e.g. see // https://github.com/node-fetch/node-fetch/issues/1769. - duplex: "half", + // duplex: "half", }); const res = await fetch(req); if (!res.ok) From d53a4a14b83cc17259b83fdb24cc5af01657ad02 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 16 Apr 2024 09:46:55 +0530 Subject: [PATCH 5/8] Try another reader --- desktop/src/main/stream.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/desktop/src/main/stream.ts b/desktop/src/main/stream.ts index 2d0eaa62c0..73b04b2cd0 100644 --- a/desktop/src/main/stream.ts +++ b/desktop/src/main/stream.ts @@ -39,11 +39,19 @@ export const registerStreamProtocol = () => { try { // await writeStream(path, request.body); console.log("starting stream"); - let c = 0; - for await (const p of request.body as any) { - if (c == 327680) console.log(p); - fs.appendFile(path, p); - c += p.length; + // let c = 0; + // for await (const p of request.body as any) { + // if (c == 327680) console.log(p); + // fs.appendFile(path, p); + // c += p.length; + // } + const reader = request.body.getReader(); + // eslint-disable-next-line no-constant-condition + while (true) { + const { value, done } = await reader.read(); + if (done) break; + console.log(`Received ${value.length} bytes`); + fs.appendFile(path, value); } console.log("ending stream"); From 81d1563c3d2c806da58920a26ad96e842e02c817 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 16 Apr 2024 10:17:34 +0530 Subject: [PATCH 6/8] Also reproducible on latest beta --- desktop/package.json | 2 +- desktop/yarn.lock | 8 +++---- web/apps/photos/src/utils/native-stream.ts | 28 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index 69d54f75be..1f368c4b98 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -39,7 +39,7 @@ "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", "concurrently": "^8", - "electron": "^29", + "electron": "30.0.0-beta.8", "electron-builder": "^24", "electron-builder-notarize": "^1.5", "eslint": "^8", diff --git a/desktop/yarn.lock b/desktop/yarn.lock index a5b86f1eb3..0c314db0f7 100644 --- a/desktop/yarn.lock +++ b/desktop/yarn.lock @@ -1214,10 +1214,10 @@ electron-updater@^6.1: semver "^7.3.8" tiny-typed-emitter "^2.1.0" -electron@^29: - version "29.3.0" - resolved "https://registry.yarnpkg.com/electron/-/electron-29.3.0.tgz#8e65cb08e9c0952c66d3196e1b5c811c43b8c5b0" - integrity sha512-ZxFKm0/v48GSoBuO3DdnMlCYXefEUKUHLMsKxyXY4nZGgzbBKpF/X8haZa2paNj23CLfsCKBOtfc2vsEQiOOsA== +electron@30.0.0-beta.8: + version "30.0.0-beta.8" + resolved "https://registry.yarnpkg.com/electron/-/electron-30.0.0-beta.8.tgz#c4430b9cb662ec147709deaededefe6d7dcc0522" + integrity sha512-G2IMMxUVJopiskD5G5iCQh71u1Emp+Q7nS1bWRU/9sK8bKwW1qtyBb3qoq0X9bd7y0LuKUb79AOr3Ix+J6EKaQ== dependencies: "@electron/get" "^2.0.0" "@types/node" "^20.9.0" diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts index 12b55f68b1..91934059b6 100644 --- a/web/apps/photos/src/utils/native-stream.ts +++ b/web/apps/photos/src/utils/native-stream.ts @@ -15,7 +15,35 @@ * @param stream The stream which should be written into the file. * */ export const writeStream = async (path: string, stream: ReadableStream) => { + // return writeStreamOneShot(path, stream) + // The duplex parameter needs to be set to 'half' when streaming requests. + // + // Currently browsers, and specifically in our case, since this code runs + // only within our desktop (Electron) app, Chromium, don't support 'full' + // duplex mode (i.e. streaming both the request and the response). + // https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests + const req = new Request(`stream://write${path}`, { + // GET can't have a body + method: "POST", + headers: { "Content-Type": "application/octet-stream" }, + body: stream, + // @ts-expect-error TypeScript's libdom.d.ts does not include the + // "duplex" parameter, e.g. see + // https://github.com/node-fetch/node-fetch/issues/1769. + duplex: "half", + }); + const res = await fetch(req); + if (!res.ok) + throw new Error( + `Failed to write stream to ${path}: HTTP ${res.status}`, + ); +}; + +export const writeStreamOneShot = async ( + path: string, + stream: ReadableStream, +) => { const response = new Response(stream); const blob = await response.blob(); // const ReadableStream() From 450e494a5e245d7e1553e65ca1320583f0318814 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 16 Apr 2024 11:33:03 +0530 Subject: [PATCH 7/8] Throwing darts --- desktop/src/main.ts | 39 +++++++++++++++++--- web/apps/photos/src/utils/native-stream.ts | 41 +++++++++++++++++++++- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/desktop/src/main.ts b/desktop/src/main.ts index 8526e23632..72e2b8233e 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -132,12 +132,43 @@ const registerPrivilegedSchemes = () => { // TODO(MR): Remove the commented bits if we don't end up // needing them by the time the IPC refactoring is done. - // Prevent the insecure origin issues when fetching this + // standard: true, + // // Prevent the insecure origin issues when fetching this // secure: true, - // Allow the web fetch API in the renderer to use this scheme. - supportFetchAPI: true, - // Allow it to be used with video tags. + // // Allow the web fetch API in the renderer to use this scheme. + // supportFetchAPI: true, + // // Allow it to be used with video tags. // stream: true, + standard: true, + /** + * Default false. + */ + secure: true, + /** + * Default false. + */ + bypassCSP: true, + /** + * Default false. + */ + allowServiceWorkers: true, + /** + * Default false. + */ + supportFetchAPI: true, + /** + * Default false. + */ + corsEnabled: true, + /** + * Default false. + */ + stream: true, + /** + * Enable V8 code cache for the scheme, only works when `standard` is also set to + * true. Default false. + */ + codeCache: true, }, }, ]); diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts index 91934059b6..0176a2b7cc 100644 --- a/web/apps/photos/src/utils/native-stream.ts +++ b/web/apps/photos/src/utils/native-stream.ts @@ -15,6 +15,10 @@ * @param stream The stream which should be written into the file. * */ export const writeStream = async (path: string, stream: ReadableStream) => { + writeStream_1("/tmp/1.txt", testStream()); +}; + +export const writeStream_1 = async (path: string, stream: ReadableStream) => { // return writeStreamOneShot(path, stream) // The duplex parameter needs to be set to 'half' when streaming requests. @@ -26,7 +30,10 @@ export const writeStream = async (path: string, stream: ReadableStream) => { const req = new Request(`stream://write${path}`, { // GET can't have a body method: "POST", - headers: { "Content-Type": "application/octet-stream" }, + headers: { + "Content-Type": "application/octet-stream", + "Content-Length": "1128608", + }, body: stream, // @ts-expect-error TypeScript's libdom.d.ts does not include the // "duplex" parameter, e.g. see @@ -40,6 +47,38 @@ export const writeStream = async (path: string, stream: ReadableStream) => { ); }; +const testStream = () => { + return new ReadableStream({ + async start(controller) { + const send = (count: number, char: string) => + controller.enqueue( + new TextEncoder().encode(Array(count).fill(char).join("")), + ); + + send(65536, "1"); + send(65536, "2"); + send(65536, "3"); + send(65536, "4"); + send(65536, "5"); + send(65536, "6"); + send(65536, "7"); + send(65536, "8"); + send(65536, "9"); + send(65536, "1"); + send(65536, "2"); + send(65536, "3"); + send(65536, "4"); + send(65536, "5"); + send(65536, "6"); + send(65536, "7"); + send(65536, "8"); + send(14496, "9"); + + controller.close(); + }, + }); +}; + export const writeStreamOneShot = async ( path: string, stream: ReadableStream, From 2403c19f7067d39c524eae71691ac2897c4790ab Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 16 Apr 2024 14:46:13 +0530 Subject: [PATCH 8/8] Add a temporary fallback --- desktop/package.json | 2 +- desktop/src/main.ts | 39 +--------- desktop/src/main/services/ffmpeg.ts | 2 +- desktop/src/main/services/imageProcessor.ts | 2 +- desktop/src/main/services/ml-clip.ts | 2 +- desktop/src/main/services/ml.ts | 2 +- desktop/src/main/stream.ts | 19 +---- desktop/yarn.lock | 8 +- web/apps/photos/src/utils/native-stream.ts | 82 ++++----------------- 9 files changed, 29 insertions(+), 129 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index 1f368c4b98..69d54f75be 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -39,7 +39,7 @@ "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", "concurrently": "^8", - "electron": "30.0.0-beta.8", + "electron": "^29", "electron-builder": "^24", "electron-builder-notarize": "^1.5", "eslint": "^8", diff --git a/desktop/src/main.ts b/desktop/src/main.ts index 72e2b8233e..8526e23632 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -132,43 +132,12 @@ const registerPrivilegedSchemes = () => { // TODO(MR): Remove the commented bits if we don't end up // needing them by the time the IPC refactoring is done. - // standard: true, - // // Prevent the insecure origin issues when fetching this + // Prevent the insecure origin issues when fetching this // secure: true, - // // Allow the web fetch API in the renderer to use this scheme. - // supportFetchAPI: true, - // // Allow it to be used with video tags. - // stream: true, - standard: true, - /** - * Default false. - */ - secure: true, - /** - * Default false. - */ - bypassCSP: true, - /** - * Default false. - */ - allowServiceWorkers: true, - /** - * Default false. - */ + // Allow the web fetch API in the renderer to use this scheme. supportFetchAPI: true, - /** - * Default false. - */ - corsEnabled: true, - /** - * Default false. - */ - stream: true, - /** - * Enable V8 code cache for the scheme, only works when `standard` is also set to - * true. Default false. - */ - codeCache: true, + // Allow it to be used with video tags. + // stream: true, }, }, ]); diff --git a/desktop/src/main/services/ffmpeg.ts b/desktop/src/main/services/ffmpeg.ts index 3072d5ee7b..2597bae60f 100644 --- a/desktop/src/main/services/ffmpeg.ts +++ b/desktop/src/main/services/ffmpeg.ts @@ -2,8 +2,8 @@ import pathToFfmpeg from "ffmpeg-static"; import { existsSync } from "node:fs"; import fs from "node:fs/promises"; import { ElectronFile } from "../../types/ipc"; -import { writeStream } from "../stream"; import log from "../log"; +import { writeStream } from "../stream"; import { generateTempFilePath, getTempDirPath } from "../temp"; import { execAsync } from "../util"; diff --git a/desktop/src/main/services/imageProcessor.ts b/desktop/src/main/services/imageProcessor.ts index d87fb0c5f2..696119d80f 100644 --- a/desktop/src/main/services/imageProcessor.ts +++ b/desktop/src/main/services/imageProcessor.ts @@ -2,9 +2,9 @@ import { existsSync } from "fs"; import fs from "node:fs/promises"; import path from "path"; import { CustomErrors, ElectronFile } from "../../types/ipc"; -import { writeStream } from "../stream"; import log from "../log"; import { isPlatform } from "../platform"; +import { writeStream } from "../stream"; import { generateTempFilePath } from "../temp"; import { execAsync, isDev } from "../util"; import { deleteTempFile } from "./ffmpeg"; diff --git a/desktop/src/main/services/ml-clip.ts b/desktop/src/main/services/ml-clip.ts index af8198a3cf..46af2552bc 100644 --- a/desktop/src/main/services/ml-clip.ts +++ b/desktop/src/main/services/ml-clip.ts @@ -11,8 +11,8 @@ import fs from "node:fs/promises"; import * as ort from "onnxruntime-node"; import Tokenizer from "../../thirdparty/clip-bpe-ts/mod"; import { CustomErrors } from "../../types/ipc"; -import { writeStream } from "../stream"; import log from "../log"; +import { writeStream } from "../stream"; import { generateTempFilePath } from "../temp"; import { deleteTempFile } from "./ffmpeg"; import { diff --git a/desktop/src/main/services/ml.ts b/desktop/src/main/services/ml.ts index e1d68e2ddd..60e8241e16 100644 --- a/desktop/src/main/services/ml.ts +++ b/desktop/src/main/services/ml.ts @@ -15,8 +15,8 @@ import { existsSync } from "fs"; import fs from "node:fs/promises"; import path from "node:path"; import * as ort from "onnxruntime-node"; -import { writeStream } from "../stream"; import log from "../log"; +import { writeStream } from "../stream"; /** * Download the model named {@link modelName} if we don't already have it. diff --git a/desktop/src/main/stream.ts b/desktop/src/main/stream.ts index 73b04b2cd0..8ddb80dc6a 100644 --- a/desktop/src/main/stream.ts +++ b/desktop/src/main/stream.ts @@ -37,24 +37,7 @@ export const registerStreamProtocol = () => { /* host-pathname----- */ case "write": try { - // await writeStream(path, request.body); - console.log("starting stream"); - // let c = 0; - // for await (const p of request.body as any) { - // if (c == 327680) console.log(p); - // fs.appendFile(path, p); - // c += p.length; - // } - const reader = request.body.getReader(); - // eslint-disable-next-line no-constant-condition - while (true) { - const { value, done } = await reader.read(); - if (done) break; - console.log(`Received ${value.length} bytes`); - fs.appendFile(path, value); - } - console.log("ending stream"); - + await writeStream(path, request.body); return new Response("", { status: 200 }); } catch (e) { log.error(`Failed to write stream for ${url}`, e); diff --git a/desktop/yarn.lock b/desktop/yarn.lock index 0c314db0f7..a5b86f1eb3 100644 --- a/desktop/yarn.lock +++ b/desktop/yarn.lock @@ -1214,10 +1214,10 @@ electron-updater@^6.1: semver "^7.3.8" tiny-typed-emitter "^2.1.0" -electron@30.0.0-beta.8: - version "30.0.0-beta.8" - resolved "https://registry.yarnpkg.com/electron/-/electron-30.0.0-beta.8.tgz#c4430b9cb662ec147709deaededefe6d7dcc0522" - integrity sha512-G2IMMxUVJopiskD5G5iCQh71u1Emp+Q7nS1bWRU/9sK8bKwW1qtyBb3qoq0X9bd7y0LuKUb79AOr3Ix+J6EKaQ== +electron@^29: + version "29.3.0" + resolved "https://registry.yarnpkg.com/electron/-/electron-29.3.0.tgz#8e65cb08e9c0952c66d3196e1b5c811c43b8c5b0" + integrity sha512-ZxFKm0/v48GSoBuO3DdnMlCYXefEUKUHLMsKxyXY4nZGgzbBKpF/X8haZa2paNj23CLfsCKBOtfc2vsEQiOOsA== dependencies: "@electron/get" "^2.0.0" "@types/node" "^20.9.0" diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts index 0176a2b7cc..7dba1acf9c 100644 --- a/web/apps/photos/src/utils/native-stream.ts +++ b/web/apps/photos/src/utils/native-stream.ts @@ -15,12 +15,19 @@ * @param stream The stream which should be written into the file. * */ export const writeStream = async (path: string, stream: ReadableStream) => { - writeStream_1("/tmp/1.txt", testStream()); -}; - -export const writeStream_1 = async (path: string, stream: ReadableStream) => { - // return writeStreamOneShot(path, stream) + // TODO(MR): This doesn't currently work. + // + // Not sure what I'm doing wrong here; I've opened an issue upstream + // https://github.com/electron/electron/issues/41872 + // + // A gist with a minimal reproduction + // https://gist.github.com/mnvr/e08d9f4876fb8400b7615347b4d268eb + // + // Meanwhile, write the complete body in one go (this'll eventually run into + // memory failures with large files - just a temporary stopgap to get the + // code to work). + /* // The duplex parameter needs to be set to 'half' when streaming requests. // // Currently browsers, and specifically in our case, since this code runs @@ -30,78 +37,19 @@ export const writeStream_1 = async (path: string, stream: ReadableStream) => { const req = new Request(`stream://write${path}`, { // GET can't have a body method: "POST", - headers: { - "Content-Type": "application/octet-stream", - "Content-Length": "1128608", - }, body: stream, // @ts-expect-error TypeScript's libdom.d.ts does not include the // "duplex" parameter, e.g. see // https://github.com/node-fetch/node-fetch/issues/1769. duplex: "half", }); - const res = await fetch(req); - if (!res.ok) - throw new Error( - `Failed to write stream to ${path}: HTTP ${res.status}`, - ); -}; + */ -const testStream = () => { - return new ReadableStream({ - async start(controller) { - const send = (count: number, char: string) => - controller.enqueue( - new TextEncoder().encode(Array(count).fill(char).join("")), - ); - - send(65536, "1"); - send(65536, "2"); - send(65536, "3"); - send(65536, "4"); - send(65536, "5"); - send(65536, "6"); - send(65536, "7"); - send(65536, "8"); - send(65536, "9"); - send(65536, "1"); - send(65536, "2"); - send(65536, "3"); - send(65536, "4"); - send(65536, "5"); - send(65536, "6"); - send(65536, "7"); - send(65536, "8"); - send(14496, "9"); - - controller.close(); - }, - }); -}; - -export const writeStreamOneShot = async ( - path: string, - stream: ReadableStream, -) => { - const response = new Response(stream); - const blob = await response.blob(); - // const ReadableStream() - - // The duplex parameter needs to be set to 'half' when streaming requests. - // - // Currently browsers, and specifically in our case, since this code runs - // only within our desktop (Electron) app, Chromium, don't support 'full' - // duplex mode (i.e. streaming both the request and the response). - // https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests const req = new Request(`stream://write${path}`, { - // GET can't have a body method: "POST", - body: blob, - // @ts-expect-erroXXX TypeScript's libdom.d.ts does not include the - // "duplex" parameter, e.g. see - // https://github.com/node-fetch/node-fetch/issues/1769. - // duplex: "half", + body: await new Response(stream).blob(), }); + const res = await fetch(req); if (!res.ok) throw new Error(