Skip to content

Commit 5201ada

Browse files
committed
refactor(bundle-source): use jessie.js asyncGenerate to avoid no-await-in-loop
1 parent 88191c5 commit 5201ada

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/bundle-source/cache.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { makePromiseKit } from '@endo/promise-kit';
33
import { makeReadPowers } from '@endo/compartment-mapper/node-powers.js';
44

5+
import { asyncGenerate } from 'jessie.js';
6+
57
import bundleSource from './src/index.js';
68

79
const { Fail, quote: q } = assert;
@@ -198,10 +200,15 @@ export const makeBundleCache = (wr, cwd, readPowers, opts) => {
198200
const lockRd = wr.readOnly().neighbor(toBundleLock(targetName));
199201

200202
// Wait for the bundle to be written.
201-
// eslint-disable-next-line no-await-in-loop
202-
while (await lockRd.exists()) {
203+
const lockDone = async () => {
204+
const notDone = await lockRd.exists();
205+
return {
206+
done: !notDone,
207+
value: undefined,
208+
};
209+
};
210+
for await (const _ of asyncGenerate(lockDone)) {
203211
log(`${wr}`, 'waiting for bundle read lock:', `${lockRd}`, 'in', rootOpt);
204-
// eslint-disable-next-line no-await-in-loop
205212
await readPowers.delay(1000);
206213
}
207214

packages/bundle-source/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@rollup/plugin-commonjs": "^19.0.0",
3838
"@rollup/plugin-node-resolve": "^13.0.0",
3939
"acorn": "^8.2.4",
40+
"jessie.js": "^0.3.2",
4041
"rollup": "endojs/endo#rollup-2.7.1-patch-1",
4142
"source-map": "^0.7.3"
4243
},

0 commit comments

Comments
 (0)