diff --git a/lib/ipni-client.js b/lib/ipni-client.js index f93a63c..2a13437 100644 --- a/lib/ipni-client.js +++ b/lib/ipni-client.js @@ -16,7 +16,7 @@ export async function queryTheIndex (cid, providerId) { try { const res = await fetch(url) if (!res.ok) { - console.error('IPNI query failed, HTTP response: %s %s', res.status, await res.text()) + console.error('IPNI query failed, HTTP response: %s %s', res.status, (await res.text()).trimEnd()) return { indexerResult: `ERROR_${res.status}` } } diff --git a/lib/miner-info.js b/lib/miner-info.js index f69db09..0761184 100644 --- a/lib/miner-info.js +++ b/lib/miner-info.js @@ -36,7 +36,7 @@ async function rpc (method, ...params) { const res = await fetch(req) if (!res.ok) { - throw new Error(`JSON RPC failed with ${res.code}: ${await res.text()}`) + throw new Error(`JSON RPC failed with ${res.code}: ${(await res.text()).trimEnd()}`) } const body = await res.json() diff --git a/lib/spark.js b/lib/spark.js index f731832..168de42 100644 --- a/lib/spark.js +++ b/lib/spark.js @@ -153,14 +153,13 @@ export default class Spark { } } else { console.error('Retrieval failed with status code %s: %s', - res.status, await res.text()) + res.status, (await res.text()).trimEnd()) } } finally { clearTimeout(timeout) } stats.endAt = new Date() - console.log(stats) } async submitMeasurement (task, stats) { @@ -226,6 +225,7 @@ export default class Spark { if (delay > 0) { console.log('Sleeping for %s seconds before starting the next task...', Math.round(delay / 1000)) await sleep(delay) + console.log() // add an empty line to visually delimit logs from different tasks } } } @@ -247,7 +247,7 @@ async function assertOkResponse (res, errorMsg) { try { body = await res.text() } catch {} - const err = new Error(`${errorMsg ?? 'Fetch failed'} (${res.status}): ${body}`) + const err = new Error(`${errorMsg ?? 'Fetch failed'} (${res.status}): ${body.trimEnd()}`) err.statusCode = res.status err.serverMessage = body throw err diff --git a/manual-check.js b/manual-check.js index 50906cd..5b83efe 100644 --- a/manual-check.js +++ b/manual-check.js @@ -13,3 +13,4 @@ const minerId = 'f010479' const spark = new Spark() const stats = { cid, minerId, indexerResult: null, statusCode: null, byteLength: 0 } await spark.executeRetrievalCheck({ cid, minerId }, stats) +console.log('Measurement: %o', stats)