Skip to content

Commit

Permalink
Compatibility with older SDK without solo slog (#48)
Browse files Browse the repository at this point in the history
Makes the solo slog optional, and conditionally pipes the streams to avoid failures.
  • Loading branch information
mhofman authored Feb 2, 2022
2 parents 56b9021 + 58ab445 commit 90474ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
17 changes: 13 additions & 4 deletions runner/lib/tasks/local-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,14 @@ export const makeTasks = ({
const slogFifo = await makeFIFO('client.slog');
const slogReady = fsStreamReady(slogFifo);
const slogLines = new BufferLineTransform();
const slogPipeResult = pipeline(slogFifo, slogLines);
const slogPipeResult = slogReady.then(() =>
slogLines.writableEnded ? undefined : pipeline(slogFifo, slogLines),
);

const clientEnv = Object.create(process.env);
clientEnv.SOLO_SLOGFILE = slogFifo.path;

const soloCp = printerSpawn(sdkBinaries.agSolo, ['start'], {
const soloCp = printerSpawn(sdkBinaries.agSolo, ['start', '--verbose'], {
stdio: ['ignore', 'pipe', 'pipe'],
cwd: clientStateDir,
env: clientEnv,
Expand Down Expand Up @@ -429,7 +431,14 @@ export const makeTasks = ({
clientDone,
]).then(() => {});

const ready = PromiseAllOrErrors([walletReady, slogReady]).then(() => {});
walletReady
.then(() =>
Promise.race([
slogReady,
Promise.reject(new Error('Slog not supported')),
]),
)
.catch((err) => console.warn(err.message || err));

return tryTimeout(
timeout * 1000,
Expand All @@ -451,7 +460,7 @@ export const makeTasks = ({
return harden({
stop,
done,
ready,
ready: walletReady,
slogLines: cleanAsyncIterable(slogLines),
storageLocation: clientStateDir,
processInfo,
Expand Down
17 changes: 13 additions & 4 deletions runner/lib/tasks/testnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,14 @@ ${chainName} chain does not yet know of address ${soloAddr}
const slogFifo = await makeFIFO('client.slog');
const slogReady = fsStreamReady(slogFifo);
const slogLines = new BufferLineTransform();
const slogPipeResult = pipeline(slogFifo, slogLines);
const slogPipeResult = slogReady.then(() =>
slogLines.writableEnded ? undefined : pipeline(slogFifo, slogLines),
);

const clientEnv = Object.create(process.env);
clientEnv.SOLO_SLOGFILE = slogFifo.path;

const soloCp = printerSpawn(sdkBinaries.agSolo, ['start'], {
const soloCp = printerSpawn(sdkBinaries.agSolo, ['start', '--verbose'], {
stdio: ['ignore', 'pipe', 'pipe'],
cwd: clientStateDir,
env: clientEnv,
Expand Down Expand Up @@ -517,7 +519,14 @@ ${chainName} chain does not yet know of address ${soloAddr}
clientDone,
]).then(() => {});

const ready = PromiseAllOrErrors([walletReady, slogReady]).then(() => {});
walletReady
.then(() =>
Promise.race([
slogReady,
Promise.reject(new Error('Slog not supported')),
]),
)
.catch((err) => console.warn(err.message || err));

return tryTimeout(
timeout * 1000,
Expand All @@ -539,7 +548,7 @@ ${chainName} chain does not yet know of address ${soloAddr}
return harden({
stop,
done,
ready,
ready: walletReady,
slogLines: cleanAsyncIterable(slogLines),
storageLocation: clientStateDir,
processInfo,
Expand Down

0 comments on commit 90474ae

Please sign in to comment.