Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ export const preprocess = async ({
* @returns {Promise<import('./typings.js').RawMeasurement[]>}
*/
export const fetchMeasurements = async (cid, { signal, noCache = false } = {}) => {
if (cid === 'bafkqaaa' || cid === 'bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku') {
// These CIDs represent an empty file
return []
}

const res = await fetch(
`https://${encodeURIComponent(cid)}.ipfs.w3s.link?format=car`,
{
Expand Down
17 changes: 16 additions & 1 deletion test/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
preprocess,
Measurement,
parseMeasurements,
assertValidMeasurement
assertValidMeasurement,
fetchMeasurements
} from '../lib/preprocess.js'
import { Point } from '../lib/telemetry.js'
import assert from 'node:assert'
Expand Down Expand Up @@ -86,6 +87,20 @@ describe('preprocess', () => {
})
})

describe('fetchMeasurements', () => {
it('handles empty batch with CID bafkqaaa', async () => {
const cid = 'bafkqaaa'
const measurements = await fetchMeasurements(cid)
assert.deepStrictEqual(measurements, [])
})

it('handles empty batch with CID bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku', async () => {
const cid = 'bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'
const measurements = await fetchMeasurements(cid)
assert.deepStrictEqual(measurements, [])
})
})

describe('parseMeasurements', () => {
const measurements = [{ foo: 'bar' }, { beep: 'boop' }]
it('parses a JSON array', () => {
Expand Down