Skip to content

Commit

Permalink
chore: resolve floating-promise warnings in kernel packages
Browse files Browse the repository at this point in the history
closes #8210
refs: #6000
  • Loading branch information
toliaqat committed Aug 17, 2023
1 parent de82c94 commit 786e96f
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/SwingSet/misc-tools/extract-xs-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if (!vatIDToExtract) {
const { snapPos, hash } = info;
const snapshot = snapStore.loadSnapshot(vatIDToExtract);
const fn = `${vatIDToExtract}-${snapPos}-${hash}.xss`;
E.when(fs.promises.writeFile(fn, snapshot), () =>
void E.when(fs.promises.writeFile(fn, snapshot), () =>
console.log(`wrote snapshot to ${fn}`),
);
}
4 changes: 2 additions & 2 deletions packages/SwingSet/test/test-vat-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ test('brand', async t => {
const whenNobrand = 123n;
const delayNobrand = 123n;
ts.setWakeup(whenNobrand, handler);
ts.wakeAt(whenNobrand);
ts.delay(delayNobrand);
void ts.wakeAt(whenNobrand);
void ts.delay(delayNobrand);
ts.makeRepeater(delayNobrand, delayNobrand);
ts.repeatAfter(delayNobrand, delayNobrand, handler);
ts.makeNotifier(delayNobrand, delayNobrand);
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/transcript/test-state-sync-reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test('state-sync reload', async t => {
const { commit } = hostStorage;
const initOpts = { addComms: false, addVattp: false, addTimer: false };
await initializeSwingset(config, [], kernelStorage, initOpts);
commit();
void commit();

const { runtimeOptions } = t.context.data;
const c1 = await makeSwingsetController(kernelStorage, {}, runtimeOptions);
Expand All @@ -82,7 +82,7 @@ test('state-sync reload', async t => {
t.is(res, i);
}

commit();
void commit();
await c1.shutdown();

const exporter = makeSwingStoreExporter(dbDir);
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/transcript/test-transcript-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ test('transcript spans', async t => {
const { commit } = hostStorage;
const initOpts = { addComms: false, addVattp: false, addTimer: false };
await initializeSwingset(config, [], kernelStorage, initOpts);
commit();
void commit();

let c;
const restart = async () => {
if (c) {
commit();
void commit();
await c.shutdown();
}
const { runtimeOptions } = t.context.data;
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/scripts/clean-core-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const main = async (argv, { readFile, stdout }) => {

if (isEntrypoint(import.meta.url)) {
/* global process */
farExports.E.when(
void farExports.E.when(
import('fs/promises'),
fsp =>
main([...process.argv], {
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/src/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const makeWithQueue = () => {
}
const [thunk, resolve, reject] = queue[0];
// Run the thunk in a new turn.
Promise.resolve()
void Promise.resolve()
.then(thunk)
// Resolve or reject our caller with the thunk's value.
.then(resolve, reject)
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function run() {
commands[commands.length - 1] = inp.value;
commands[commands.length] = '';
inp.value = '';
call({ type: 'doEval', number, body: command });
void call({ type: 'doEval', number, body: command });
}

function inputKeyup(ev) {
Expand Down
12 changes: 9 additions & 3 deletions packages/solo/src/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const getCapTPHandler = (send, getLocalBootstrap, fallback) => {
dispatch,
abort,
});
doFallback('onOpen', obj, meta);
doFallback('onOpen', obj, meta).catch(e => {
console.error(`Error in fallback onOpen`, e);
});
},
onClose(obj, meta) {
console.debug(`Finishing CapTP`, meta);
Expand All @@ -53,7 +55,9 @@ export const getCapTPHandler = (send, getLocalBootstrap, fallback) => {
abort();
}
chans.delete(meta.channelHandle);
doFallback('onClose', obj, meta);
doFallback('onClose', obj, meta).catch(e => {
console.error(`Error in fallback onClose`, e);
});
},
onError(obj, meta) {
console.debug(`Error in CapTP`, meta, obj.error);
Expand All @@ -62,7 +66,9 @@ export const getCapTPHandler = (send, getLocalBootstrap, fallback) => {
const { abort } = chan;
abort(obj.error);
}
doFallback('onError', obj, meta);
doFallback('onError', obj, meta).catch(e => {
console.error(`Error in fallback onError`, e);
});
},
async onMessage(obj, meta) {
console.debug('processing inbound', obj);
Expand Down
27 changes: 16 additions & 11 deletions packages/solo/src/chain-cosmos-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export async function connectToChain(
*/
const getMailboxNotifier = () => {
const { notifier, updater } = makeNotifierKit();
retryRpcHref(async rpcHref => {
void retryRpcHref(async rpcHref => {
// Every time we enter this function, we are establishing a
// new websocket to a potentially different RPC server.
//
Expand Down Expand Up @@ -486,7 +486,7 @@ export async function connectToChain(

waitForTxHash = subscribeAndWaitForTxHash;
if (postponedTxHash) {
subscribeAndWaitForTxHash(postponedTxHash);
void subscribeAndWaitForTxHash(postponedTxHash);
}

subscribeToStorage(`mailbox.${clientAddr}`, (err, storageValue) => {
Expand Down Expand Up @@ -692,15 +692,20 @@ ${chainID} chain does not yet know of address ${clientAddr}${adviseEgress(
// Wait for the transaction to be included in a block.
const txHash = out.txhash;

waitForTxHash(txHash).then(txResult => {
// The result had an error code (not 0 or undefined for success).
if (txResult.code) {
waitForTxHash(txHash)
.then(txResult => {
// The result had an error code (not 0 or undefined for success).
if (txResult.code) {
// eslint-disable-next-line no-use-before-define
failedSend(
assert.error(`Error in tx processing: ${txResult.log}`),
);
}
})
.catch(err =>
// eslint-disable-next-line no-use-before-define
failedSend(
assert.error(`Error in tx processing: ${txResult.log}`),
);
}
});
failedSend(assert.error(`Error in tx processing: ${err}`)),
);

// We submitted the transaction to the mempool successfully.
// Preemptively increment our sequence number to avoid needing to
Expand Down Expand Up @@ -778,7 +783,7 @@ ${chainID} chain does not yet know of address ${clientAddr}${adviseEgress(
updateCount || Fail`Sending unexpectedly finished!`;

await sendFromMessagePool().then(successfulSend, failedSend);
recurseEachSend(updateCount);
void recurseEachSend(updateCount);
};

// Begin the sender when we get the first (empty) mailbox update.
Expand Down
4 changes: 2 additions & 2 deletions packages/solo/src/vat-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function buildRootObject(vatPowers) {
commandDevice = d;

const replHandler = getReplHandler(replObjects, send);
registerURLHandler(replHandler, '/private/repl');
void registerURLHandler(replHandler, '/private/repl');

// Assign the captp handler.
const captpHandler = Far('captpHandler', {
Expand All @@ -127,7 +127,7 @@ export function buildRootObject(vatPowers) {
return harden(exported);
},
});
registerURLHandler(captpHandler, '/private/captp');
void registerURLHandler(captpHandler, '/private/captp');
},

registerURLHandler,
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/test/captp-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export async function makeFixture(PORT, noisy = false) {
// We only reject if the child exits before CapTP is established.
reject(Error(`CapTP fixture exited with ${code}`));
});
tryConnect(resolve, reject);
void tryConnect(resolve, reject);
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-liveslots/src/liveslots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ function build(
// *not* directly wait for the userspace function to complete, nor for
// any promise it returns to fire.
const p = Promise.resolve(delivery).then(unmeteredDispatch);
p.finally(() => (complete = true));
void p.finally(() => (complete = true));

// Instead, we wait for userspace to become idle by draining the
// promise queue. We clean up and then examine/return 'p' so any
Expand Down
10 changes: 5 additions & 5 deletions packages/xsnap/src/xsnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export async function xsnap(options) {
sourceStream.pipe(destStream, { end: false });

done = finished(sourceStream);
done.catch(noop).then(() => sourceStream.unpipe(destStream));
done.catch(noop).then(() => sourceStream.unpipe(destStream), noop);
};

return harden({
Expand Down Expand Up @@ -264,7 +264,7 @@ export async function xsnap(options) {
loadSnapshotHandler = undefined;
return cleanup();
}
});
}, noop);
}

/** @type {Promise<void>} */
Expand Down Expand Up @@ -458,10 +458,10 @@ export async function xsnap(options) {
const handle = await fs.open(snapPath, 'w+');
// @ts-expect-error 'close' event added in Node 15.4
handle.on('close', () => {
fs.unlink(snapPath);
void fs.unlink(snapPath);
});
sourceStream = handle.createReadStream();
finished(output).finally(() => sourceStream.destroy());
void finished(output).finally(() => sourceStream.destroy());
} else {
sourceStream = snapshotSaveStream;
snapPath = `@${SNAPSHOT_SAVE_FD}`;
Expand All @@ -470,7 +470,7 @@ export async function xsnap(options) {
// ensuring that any previous save stream usage has ended. However we
// must start the flow before receiving the command's response or the
// xsnap process would block on a full pipe, causing an IPC deadlock.
batonKit.promise.then(maybePipe);
batonKit.promise.then(maybePipe, noop);
}

const cleanup = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/xsnap/src/xsrepl.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ async function main() {
return vat.close();
}

main();
await main();
2 changes: 1 addition & 1 deletion packages/xsnap/test/fixture-xsnap-script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint @typescript-eslint/no-floating-promises: "warn" */
/* global issueCommand */
(async () => {
void (async () => {
issueCommand(new TextEncoder().encode('Hello, World!').buffer);
})();

0 comments on commit 786e96f

Please sign in to comment.