diff --git a/CHANGELOG.md b/CHANGELOG.md index d729d40..0584857 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,15 @@ All notable changes to MeterX are documented here. The format follows [Keep a Ch ### Added - Support links: "Support on Ko-fi" in the site footer and the extension's options page (plain links, nothing new loads), and a Support section in the README with Ko-fi and a UPI QR code +### Changed +- Upload streams resize each body from how long the last one took, aiming at about 1 s per request, so a test makes far fewer server requests and the free quota covers several times more tests + ### Fixed - Tests run from a private or incognito window are no longer saved to history; the result still shows (#97) +- Chrome and Edge uploads stalled on some networks (seen on Jio): Chrome used HTTP/3 to the test server, and uploads over it hung until the test gave up. The default test server is now `meterx-api.ajithakdev.com`, served without HTTP/3. The extension asks for access to the new address once; the old `workers.dev` address keeps working for older versions +- Upload read about half of the real speed in Chrome on fast lines (BSNL 60/60: 14 to 29 Mbps against curl's 55 to 66), because Chrome sends uploads over HTTP/2 slowly. Uploads now go to the worker's `workers.dev` address over HTTP/3 and read 53 to 66 Mbps on the same line. If an upload request there fails, or a stream's first upload stays open over 3 s as on Jio, the upload phase starts again on `meterx-api.ajithakdev.com` (#104) +- Upload read far too low, or failed with "No data reached the server", on lines with a much slower upload than download (for example Jio 5G: 124 Mbps down, about 4 up). The first upload body was sized from the download speed and could not finish in time; every stream now starts at 256 KB and grows from what it measures (#60) +- The worker serves `/ping` as a static asset, which Cloudflare does not count against the free plan's 100,000 requests a day. About 35 of a test's 150 requests are pings, so the same quota now covers about 30% more tests, with no extension update. An A/B test on 2026-11-21 showed the same ping times. Downloads stay on the Worker: as static assets, each request waited about 180 ms longer for its first byte - A custom server URL typed with a trailing slash (`https://host/`) failed every test with 404s; Settings now tidies it before testing and saving (#68) ## [2027.0.2] - 2026-10-31 diff --git a/CLAUDE.md b/CLAUDE.md index f1fcf9a..8a717d0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -60,6 +60,6 @@ Custom server URLs need a runtime host-permission grant (`optional_host_permissi - The version lives only in the root `package.json`. `@meterx/shared` exports it as `VERSION` (used by `/health`, the exports and the settings footer), and `build.mjs` stamps it into `dist/manifest.json`, so it must be 1 to 4 dot-separated numbers. Bump that one line to release. - `manifest.json` description must stay within the store's 132-character limit. -- Store packages: Chromium stores share one zip; Firefox gets a converted manifest (sidebar, background script, id `meterx@ajithakdev`). The default worker URL is `WORKER_URL` in shared, and also sits in `host_permissions` in the extension's `static/manifest.json` and the site's `static/_headers` CSP; change all three together. +- Store packages: Chromium stores share one zip; Firefox gets a converted manifest (sidebar, background script, id `meterx@ajithakdev`). The default worker URL is `WORKER_URL` in shared, and also sits in `host_permissions` in the extension's `static/manifest.json` and the site's `static/_headers` CSP; change all three together. `WORKER_H3_URL` (the same worker on workers.dev, which keeps HTTP/3) is where uploads go first; it is in `host_permissions` too, and the site never uploads so its CSP leaves it out. - Nothing deploys on merge. The worker (`wrangler deploy`), the site (Pages direct upload, not git-connected) and the stores are released by hand on Sunday, so docs-only merges are just merges. - License is AGPL-3.0; see `TRADEMARK.md` before touching branding. diff --git a/RESOURCES-AND-GUIDE.md b/RESOURCES-AND-GUIDE.md index 3d1d127..31b08fc 100644 --- a/RESOURCES-AND-GUIDE.md +++ b/RESOURCES-AND-GUIDE.md @@ -8,7 +8,7 @@ Every link for MeterX, what it is for, and how to run, package and release it. P - Code: https://github.com/ajithakdev/meterx (was `meterx-server`; GitHub redirects the old URL) - `npm run build`, `npm test`, `npm run lint` from the root; `npm run package` writes the store uploads to `release/`. - Releases are weekly on Sunday: tag, GitHub release, `wrangler deploy` for the worker, store uploads, site deploy. -- Default test server: https://meterx-speedtest.meterx-ajithakdev.workers.dev +- Default test server: https://meterx-api.ajithakdev.com ## Links and what each one is for @@ -24,7 +24,8 @@ Every link for MeterX, what it is for, and how to run, package and release it. P | https://addons.mozilla.org/firefox/addon/meterx-by-ajithakdev/ | Firefox listing (add-on id `meterx@ajithakdev`), 2027.0.1 live since 2026-10-27 | | https://microsoftedge.microsoft.com/addons/detail/glkpolbkpachomgmmhdkmjnghejbhlfc | Microsoft Edge listing (2027.0.1 in review from 2026-10-27) | | Opera Add-ons | Not public yet: 2027.0.1 awaiting moderation (slug `meterx-by-ajithakdev-2`). Add the link to `apps/site/src/stores.ts` and the README once it's public | -| https://meterx-speedtest.meterx-ajithakdev.workers.dev | Default test server (Cloudflare Worker) | +| https://meterx-api.ajithakdev.com | Default test server (Cloudflare Worker), HTTP/2 only | +| https://meterx-speedtest.meterx-ajithakdev.workers.dev | Same worker with HTTP/3: uploads go here first and fall back to meterx-api if a request fails or the first one stalls | | https://ko-fi.com/ajithakdev | Tips. Linked from the README, the site footer and the extension options page | ### Behind the scenes diff --git a/apps/extension/src/background/measure.test.ts b/apps/extension/src/background/measure.test.ts index c1d743c..b35cd2c 100644 --- a/apps/extension/src/background/measure.test.ts +++ b/apps/extension/src/background/measure.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { toMbps, bytesAtTime, steadyMbps, median, latencyStats, gradeBufferbloat, uploadChunkBytes, backoffMs } from './measure'; +import { toMbps, bytesAtTime, steadyMbps, median, latencyStats, gradeBufferbloat, nextUploadChunk, backoffMs } from './measure'; const opts = { rampMs: 1000, tailMs: 500, durationMs: 8000 }; @@ -64,17 +64,18 @@ describe('gradeBufferbloat', () => { }); }); -describe('uploadChunkBytes', () => { - it('uses small bodies on slow links so requests finish (#60)', () => { - expect(uploadChunkBytes(10, 3)).toBe(256 * 1024); - expect(uploadChunkBytes(undefined, 3)).toBe(256 * 1024); - }); - it('caps bodies on fast links', () => { - expect(uploadChunkBytes(5000, 3)).toBe(8 * 1024 * 1024); - }); - it('targets about 4 completions per second per stream', () => { - // 300 Mbps over 3 streams = 12.5 MB/s per stream, quarter of that per body. - expect(uploadChunkBytes(300, 3)).toBe(3_125_000); +describe('nextUploadChunk', () => { + it('sizes the next body to take about 1 s', () => { + expect(nextUploadChunk(1_000_000, 250)).toBe(4_000_000); + expect(nextUploadChunk(2_000_000, 2000)).toBe(1_000_000); + }); + it('grows at most 4x per request, so a slow uplink still completes bodies (#60)', () => { + expect(nextUploadChunk(300_000, 10)).toBe(1_200_000); + expect(nextUploadChunk(300_000, 0)).toBe(1_200_000); + }); + it('stays within the min and max body sizes', () => { + expect(nextUploadChunk(256 * 1024, 5000)).toBe(256 * 1024); + expect(nextUploadChunk(8 * 1024 * 1024, 100)).toBe(8 * 1024 * 1024); }); }); diff --git a/apps/extension/src/background/measure.ts b/apps/extension/src/background/measure.ts index 17792aa..4574754 100644 --- a/apps/extension/src/background/measure.ts +++ b/apps/extension/src/background/measure.ts @@ -55,19 +55,21 @@ export function latencyStats(latencies: number[], attempts: number): { ping: num const KB = 1024; -const MIN_UPLOAD_CHUNK = 256 * KB; -const MAX_UPLOAD_CHUNK = 8 * 1024 * KB; +/** Every upload stream starts here and grows from what it measures, so lopsided lines (fast down, slow up) still finish bodies (#60). */ +export const MIN_UPLOAD_CHUNK = 256 * KB; +export const MAX_UPLOAD_CHUNK = 8 * 1024 * KB; + +const UPLOAD_TARGET_MS = 1000; /** - * Upload body size so each stream finishes about 4 requests a second. - * Bytes only count when a request completes, so fixed 5 MB bodies read - * 0 Mbps on slow uplinks (#60). Sized from the download speed, which is - * known by then and is usually the higher of the two. + * Next body size for one upload stream, from how long its last body took: aims at about + * 1 s per request, so a test spends about 24 Worker requests on uploads instead of about 96. + * Grows at most 4x per step, so a slow uplink behind a fast downlink still completes bodies (#60). */ -export function uploadChunkBytes(downloadMbps: number | undefined, streams: number): number { - const perStreamBytesPerSec = ((downloadMbps || 0) * 1e6) / 8 / Math.max(1, streams); - const target = Math.round(perStreamBytesPerSec / 4); - return Math.min(MAX_UPLOAD_CHUNK, Math.max(MIN_UPLOAD_CHUNK, target)); +export function nextUploadChunk(lastBytes: number, lastMs: number): number { + const ideal = lastMs > 0 ? (lastBytes * UPLOAD_TARGET_MS) / lastMs : lastBytes * 4; + const next = Math.round(Math.min(ideal, lastBytes * 4)); + return Math.min(MAX_UPLOAD_CHUNK, Math.max(MIN_UPLOAD_CHUNK, next)); } /** Delay before retrying a failed transfer request: 250 ms, doubling, capped at 2 s (#65). */ diff --git a/apps/extension/src/background/runner.test.ts b/apps/extension/src/background/runner.test.ts new file mode 100644 index 0000000..e1a7624 --- /dev/null +++ b/apps/extension/src/background/runner.test.ts @@ -0,0 +1,89 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { WORKER_H3_URL, WORKER_URL } from '@meterx/shared'; +import { CancelledError, runTest } from './runner'; + +// Fake clock and fetch: every request settles after a fake delay, so a whole test runs in milliseconds. +type UploadDelay = (h3: boolean, n: number) => number | 'hang' | 429; + +function mockServer(uploadDelay: UploadDelay) { + const uploads = { h3: 0, h2: 0 }; + vi.stubGlobal('fetch', vi.fn((url: string, init: RequestInit = {}) => { + let ms = 50; + let status = 200; + let body: BodyInit | null = null; + if (url.includes('/upload')) { + const h3 = url.startsWith(WORKER_H3_URL); + const d = uploadDelay(h3, h3 ? ++uploads.h3 : ++uploads.h2); + if (d === 429) status = 429; + else ms = d === 'hang' ? -1 : d; + } else if (url.includes('/test-file')) body = new Uint8Array(64 * 1024); + else if (url.includes('/ip')) body = '{}'; + const signal = init.signal; + return new Promise((resolve, reject) => { + if (signal?.aborted) return reject(signal.reason); + const abort = () => { clearTimeout(t); reject(signal!.reason); }; + const t = ms < 0 ? undefined : setTimeout(() => { + signal?.removeEventListener('abort', abort); + resolve(new Response(body, { status })); + }, ms); + signal?.addEventListener('abort', abort, { once: true }); + }); + })); + return uploads; +} + +beforeEach(() => { + vi.useFakeTimers(); + vi.spyOn(performance, 'now').mockImplementation(() => Date.now()); + vi.spyOn(AbortSignal, 'timeout').mockImplementation(ms => { + const c = new AbortController(); + setTimeout(() => c.abort(new DOMException('timed out', 'TimeoutError')), ms); + return c.signal; + }); +}); + +afterEach(() => { + vi.useRealTimers(); + vi.restoreAllMocks(); + vi.unstubAllGlobals(); +}); + +async function run(signal = new AbortController().signal) { + const result = runTest(WORKER_URL, signal, () => {}); + result.catch(() => {}); // awaited below; stops an unhandled-rejection warning while time advances + await vi.advanceTimersByTimeAsync(40_000); + return result; +} + +describe('upload over HTTP/3 with HTTP/2 fallback (#104)', () => { + it('falls back to the HTTP/2 address when the first HTTP/3 body stalls', async () => { + const uploads = mockServer(h3 => (h3 ? 'hang' : 200)); + const r = await run(); + expect(uploads.h2).toBeGreaterThan(0); + expect(r.uploadSpeed).toBeGreaterThan(0); + }); + + it('stays on HTTP/3 when a later request is slow', async () => { + const uploads = mockServer((h3, n) => (h3 && n > 3 ? 5000 : 200)); + const r = await run(); + expect(uploads.h2).toBe(0); + expect(r.uploadSpeed).toBeGreaterThan(0); + }); + + it('falls back when HTTP/3 answers with an error', async () => { + const uploads = mockServer(h3 => (h3 ? 429 : 200)); + const r = await run(); + expect(uploads.h2).toBeGreaterThan(0); + expect(r.uploadSpeed).toBeGreaterThan(0); + }); + + it('a cancel during the HTTP/3 attempt does not fall back', async () => { + const ctrl = new AbortController(); + const uploads = mockServer(h3 => { + if (h3) setTimeout(() => ctrl.abort(), 500); + return h3 ? 'hang' : 200; + }); + await expect(run(ctrl.signal)).rejects.toBeInstanceOf(CancelledError); + expect(uploads.h2).toBe(0); + }); +}); diff --git a/apps/extension/src/background/runner.ts b/apps/extension/src/background/runner.ts index d1c425a..37c2099 100644 --- a/apps/extension/src/background/runner.ts +++ b/apps/extension/src/background/runner.ts @@ -7,15 +7,17 @@ /// -import type { IpInfo, TestProgress, TestResults } from '@meterx/shared'; +import { WORKER_H3_URL, WORKER_URL, type IpInfo, type TestProgress, type TestResults } from '@meterx/shared'; import { type ByteSample, backoffMs, bytesAtTime, gradeBufferbloat, latencyStats, - median, steadyMbps, toMbps, uploadChunkBytes, + median, nextUploadChunk, steadyMbps, toMbps, MAX_UPLOAD_CHUNK, MIN_UPLOAD_CHUNK, } from './measure'; const DOWNLOAD_PATH = '/test-file/25MB.bin'; const DOWNLOAD_STREAMS = 4; const UPLOAD_STREAMS = 3; +/** A stream whose first upload is still open after 3 s has stalled (HTTP/3 on Jio). Later requests have no limit, so a brief dip can't trigger it; a stream under about 0.7 Mbps up does, harmlessly. */ +const UPLOAD_STALL_MS = 3000; // Multi-stream, fixed-duration phases (the M-Lab / Ookla approach). // The worker and Express rate limits are sized for this burst; raise them if you add streams. const MEASURE_DURATION_MS = 8000; @@ -76,7 +78,7 @@ function startLoadedProbe(baseUrl: string, signal: AbortSignal): () => Promise void) => Promise, + one: (signal: AbortSignal, credit: (bytes: number) => void, stream: number) => Promise, onLive: (mbps: number) => void, ): Promise { const phase = new AbortController(); @@ -100,11 +102,11 @@ async function runStreams( } }; - const loop = async () => { + const loop = async (stream: number) => { let failures = 0; while (!both.aborted) { try { - await one(both, credit); + await one(both, credit, stream); failures = 0; } catch (e) { if (both.aborted) break; @@ -115,7 +117,7 @@ async function runStreams( }; try { - await Promise.all(Array.from({ length: streams }, loop)); + await Promise.all(Array.from({ length: streams }, (_, i) => loop(i))); } finally { clearTimeout(timer); } @@ -199,19 +201,48 @@ export async function runTest(baseUrl: string, signal: AbortSignal, report: Repo report({ phase: 'download', downloadSpeed: results.downloadSpeed }); report({ phase: 'upload', status: 'Testing upload' }); - const payload = new Uint8Array(uploadChunkBytes(results.downloadSpeed, UPLOAD_STREAMS)); - stopProbe = startLoadedProbe(baseUrl, signal); - try { - results.uploadSpeed = await runStreams(signal, UPLOAD_STREAMS, async (s, credit) => { - const res = await fetch(bust(`${baseUrl}/upload`, 'u'), { - method: 'POST', cache: 'no-store', signal: s, - headers: { 'Content-Type': 'application/octet-stream' }, body: payload, - }); - if (!res.ok) throw new HttpError(res.status); - await res.arrayBuffer(); + const payload = new Uint8Array(MAX_UPLOAD_CHUNK); + const upload = (base: string, stallMs?: number) => { + // Each stream starts small and resizes its body from its own last request (see nextUploadChunk). + const chunkOf: number[] = Array(UPLOAD_STREAMS).fill(MIN_UPLOAD_CHUNK); + const stalled = new AbortController(); + const settled: boolean[] = Array(UPLOAD_STREAMS).fill(false); + return runStreams(AbortSignal.any([signal, stalled.signal]), UPLOAD_STREAMS, async (s, credit, stream) => { + const body = payload.subarray(0, chunkOf[stream]); + const t0 = performance.now(); + try { + const res = await fetch(bust(`${base}/upload`, 'u'), { + method: 'POST', cache: 'no-store', + signal: stallMs && !settled[stream] ? AbortSignal.any([s, AbortSignal.timeout(stallMs)]) : s, + headers: { 'Content-Type': 'application/octet-stream' }, body, + }); + if (!res.ok) throw new HttpError(res.status); + await res.arrayBuffer(); + } catch (e) { + if (stallMs && !s.aborted) stalled.abort(); + throw e; + } // fetch() has no upload progress, so bytes count when each body completes. - credit(payload.byteLength); + credit(body.byteLength); + settled[stream] = true; + chunkOf[stream] = nextUploadChunk(body.byteLength, performance.now() - t0); }, mbps => report({ phase: 'upload', uploadSpeed: mbps })); + }; + stopProbe = startLoadedProbe(baseUrl, signal); + try { + // Chrome uploads over HTTP/2 read about half of a fast line, and over HTTP/3 they stall on some + // networks (Jio). The default server's uploads try its HTTP/3 address first; if any request there + // fails or a stream's first body takes over UPLOAD_STALL_MS, the phase starts again on the HTTP/2 address (#104). + if (baseUrl === WORKER_URL) { + try { + results.uploadSpeed = await upload(WORKER_H3_URL, UPLOAD_STALL_MS); + } catch (e) { + if (signal.aborted) throw e; + results.uploadSpeed = await upload(baseUrl); + } + } else { + results.uploadSpeed = await upload(baseUrl); + } } finally { results.loadedPingUp = await stopProbe(); } diff --git a/apps/extension/static/manifest.json b/apps/extension/static/manifest.json index 834b872..d0d5e7b 100644 --- a/apps/extension/static/manifest.json +++ b/apps/extension/static/manifest.json @@ -10,6 +10,7 @@ "sidePanel" ], "host_permissions": [ + "https://meterx-api.ajithakdev.com/*", "https://meterx-speedtest.meterx-ajithakdev.workers.dev/*" ], "optional_host_permissions": [ diff --git a/apps/site/static/_headers b/apps/site/static/_headers index 646050e..24e4d56 100644 --- a/apps/site/static/_headers +++ b/apps/site/static/_headers @@ -2,7 +2,7 @@ X-Content-Type-Options: nosniff Referrer-Policy: strict-origin-when-cross-origin Permissions-Policy: camera=(), microphone=(), geolocation=(), interest-cohort=() - Content-Security-Policy: default-src 'self'; connect-src 'self' https://meterx-speedtest.meterx-ajithakdev.workers.dev https://api.github.com; img-src 'self' data: https://avatars.githubusercontent.com; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; frame-ancestors 'self'; base-uri 'none'; form-action 'none' + Content-Security-Policy: default-src 'self'; connect-src 'self' https://meterx-api.ajithakdev.com https://api.github.com; img-src 'self' data: https://avatars.githubusercontent.com; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; frame-ancestors 'self'; base-uri 'none'; form-action 'none' Strict-Transport-Security: max-age=31536000 /fonts/* diff --git a/docs/CODEMAP.md b/docs/CODEMAP.md index 84ade45..f4a4270 100644 --- a/docs/CODEMAP.md +++ b/docs/CODEMAP.md @@ -37,7 +37,7 @@ Generated by `node scripts/codemap.mjs`; regenerate after moving or adding files | --- | --- | --- | | `apps/extension/build.mjs` (41) | - | | | `apps/extension/src/background/index.ts` (120) | - | MeterX service worker: runs tests, saves history, schedules, notifies. | -| `apps/extension/src/background/measure.ts` (77) | `ByteSample`, `toMbps`, `bytesAtTime`, `steadyMbps`, `latencyStats`, `uploadChunkBytes` | Pure measurement math. No I/O, so it is unit tested (measure.test.ts). | +| `apps/extension/src/background/measure.ts` (77) | `ByteSample`, `toMbps`, `bytesAtTime`, `steadyMbps`, `latencyStats`, `nextUploadChunk` | Pure measurement math. No I/O, so it is unit tested (measure.test.ts). | | `apps/extension/src/background/runner.ts` (227) | `Reporter`, `CancelledError`, `HttpError`, `runTest` | One speed test: connect, idle latency, download, upload. | | `apps/extension/src/lib/browser.ts` (55) | `validateServerUrl`, `normalizeServerUrl`, `getServerUrl`, `panelSupported`, `openPanel` | Settings and cross-browser helpers used by the service worker and the pages. | | `apps/extension/src/lib/export-data.ts` (28) | `triggerDownload`, `exportCsv`, `exportJson` | CSV and JSON downloads. The files themselves are built by @meterx/reports. | diff --git a/docs/KNOWN-ISSUES.md b/docs/KNOWN-ISSUES.md index c9272ca..112ee40 100644 --- a/docs/KNOWN-ISSUES.md +++ b/docs/KNOWN-ISSUES.md @@ -8,6 +8,7 @@ The 33 issues from the 2026-10-22 code scan were checked against `main` on 2026- | Issue | Severity | Summary | | --- | --- | --- | +| #104 | Low | Chrome uploads over HTTP/2 read about half of a fast line. Fixed for the default server by uploading over HTTP/3 first (PR #105); still applies after a fallback and to custom servers | | #21 | Low | The background listens for a `run-test` shortcut, but the manifest declares no `commands` | ## Backends diff --git a/docs/STATE.md b/docs/STATE.md index 9506200..fff0b84 100644 --- a/docs/STATE.md +++ b/docs/STATE.md @@ -1,9 +1,15 @@ # MeterX working state -Last updated: 2026-10-31, on `main` after the 2027.0.2 worker release. +Last updated: 2026-11-21, on `feat/static-test-files` (PR #105). Update this file at the end of each work session. Keep it short. Delete entries once they are done and merged. +## Decision 2026-11-21: 2-week promotion test + +Feature and UI work is frozen (bug fixes only) until about 2026-12-06. The pitch becomes "log your speed and prove it to your ISP". Plan and decision rule: see the MeterX section of `~/.claude/launch-log.md`. Under about 100 active installs by then means maintenance mode. + +Backend before promotion (branch `feat/static-test-files`): the free Worker plan allows 100,000 requests a day and a test makes about 150 (roughly 1 `/ip`, 35 pings, 10 to 20 downloads, 96 uploads), so about 660 tests a day for everyone. Done on the branch: `/ping` is a static asset (free, unlimited; same latency in a production A/B). Tried and rejected: downloads as static assets (about 180 ms more time to first byte per request, so lower results). Also done: upload bodies start at 256 KB and each stream resizes from its last request toward about 1 s (`nextUploadChunk`). This also fixed uploads on lopsided lines: on Jio (124 down, about 4 up) `main` failed 2 of 3 runs with "No data reached the server", the branch read 3.1 to 3.6 Mbps against curl's 3.6 to 4.2 (Node A/B of `runTest`, 2026-11-21). HTTP/3 is off for the `ajithakdev.com` zone (2026-11-21, so no `alt-svc: h3`). With QUIC allowed in headless Chromium, the branch's extension finished 3 of 3 tests with no errors. On BSNL FTTH 60/60, Chrome's HTTP/2 uploads read about half (median 20 to 29 against curl's 55 to 66, worse the longer the connection lives; curl's HTTP/2 does not slow down), while HTTP/3 to `workers.dev` read 54 to 66. So uploads now go to `WORKER_H3_URL` first, and any request there that fails or passes 3 s restarts the phase on `meterx-api` (#104). Headless Chromium: 65.9, 57.9, 52.6 Mbps up; with workers.dev uploads forced to hang, every test fell back and finished, about 3 s longer. A test makes about 70 requests (1 `/ip`, about 37 pings, 5 to 6 downloads, about 27 uploads), all on the same worker and quota. Not yet re-tested on Jio with the fallback. Deferred: a 429 fallback to `speed.cloudflare.com` (needs a new host permission and has no published terms; add only if traffic nears the quota). Next feature (2027.1.0): opt-in outage monitor, probes of the static `/ping` every 30 s, sleep and closed browser shown as not monitored, PDF and CSV outage report. Rejected as backends: M-Lab (4 automated tests a day, publishes IPs), Ookla, fast.com, volunteer LibreSpeed servers, Oracle Always Free (stopping idle reclaim needs Pay As You Go, which has no hard spending cap). + ## In progress (2026-10-27) 2027.0.1 is released and on every free store: Firefox live, Edge in review, Opera awaiting moderation (new entry, slug `meterx-by-ajithakdev-2`). Store steps and every field's text are in `docs/STORE-CHECKLIST.md` and `docs/STORE-LISTINGS.md`; `npm run package` builds `release/upload//`. Main has a `protect-main` ruleset, so merges need the owner's admin bypass. 2027.0.2 (2026-10-31) shipped PR #100: the worker's CPU per request is under the free plan's 10 ms limit (preview p50 4.5 ms, p90 8.0 ms), deployed as worker version `f924181d`; no extension change, so stores stay on 2027.0.1. An A/B test against the old worker showed the same speeds, but ping during download about 55 ms higher (weak signal, 10 of 13 pairs on a 480 ms link); recheck the bufferbloat grades on a low-latency line. MeterX has never been promoted; a launch plan (dev.to article, Reddit, AlternativeTo, awesome-selfhosted, the video, a rating prompt) was proposed on 2026-10-27 and not started. @@ -12,7 +18,7 @@ Next: 1. Store reviews: Edge and Opera 2027.0.1 submitted 2026-10-27 (Firefox approved the same day). Delete the old never-published Opera entry (slug `meterx-by-ajithakdev`) if it still exists. Chrome Web Store needs a paid developer fee, so it waits for the owner's call. 2. Opera listing link into `apps/site/src/stores.ts` and the README once it is public. 3. SEO one-time setup in `docs/SEO.md` (Search Console sitemap, Bing), portfolio entry. -4. Milestone 2027.1.0 (Sunday): #97 private-window history, #99 Firefox for Android, #68 settings URL, #21 shortcut. In the same release, add "appearance" to the settings list on the site privacy page (`apps/site/static/privacy/index.html`) and bump its date; the AMO copy already has it. +4. #97 (private-window history, detected with `windows.getCurrent`) and #68 (settings URL trailing slash) are fixed on `main` (2026-11-21) and ship in the next release. Still open for 2027.1.0: #99 Firefox for Android, #21 keyboard shortcuts (a feature). In the same release, add "appearance" to the settings list on the site privacy page (`apps/site/static/privacy/index.html`) and bump its date; the AMO copy already has it. 5. Issues triaged 2026-10-27: the scan's 31 fixed bugs and 7 shipped features are closed with evidence; 48 open, status comments on the partial ones (#13, #19, #54, #95). ## Releases diff --git a/docs/STORE-CHECKLIST.md b/docs/STORE-CHECKLIST.md index d7cbb21..37e4281 100644 --- a/docs/STORE-CHECKLIST.md +++ b/docs/STORE-CHECKLIST.md @@ -54,7 +54,7 @@ In each browser: | Secure transport | Default server is https. Plain http only for localhost, 127.0.0.1 and `.local` | `validateServerUrl` unchanged or still tested | | Data and privacy | No personal data collected. Results stay in browser storage. The test server sees the IP address, as any server does, and keeps no logs. Shares put the result in the link itself | Privacy policy at `https://meterx.ajithakdev.com/privacy/` still matches what the code does | | Listing is accurate | Description lists every feature, including scheduled tests and notifications | Screenshots show the current UI, not an old version | -| Works for the reviewer | No account needed. The worker must be up | `curl https://meterx-speedtest.meterx-ajithakdev.workers.dev/health` returns the new version | +| Works for the reviewer | No account needed. The worker must be up | `curl https://meterx-api.ajithakdev.com/health` returns the new version | | Name and trademarks | "MeterX by ajithakdev". No store or browser name in the extension name | Never add "for Chrome", "Opera" or "Edge" to the name | ## 4. Microsoft Edge Add-ons @@ -110,7 +110,7 @@ MeterX is an internet speed test. No account or login is needed. To test: click the toolbar icon and press Run test. The test takes about 20 seconds and measures download, upload, ping, jitter, packet loss and latency under load against -our test server (https://meterx-speedtest.meterx-ajithakdev.workers.dev), which +our test server (https://meterx-api.ajithakdev.com), which streams bytes and stores nothing. Open the side panel from the popup to see history and exports (PDF, CSV, JSON). diff --git a/docs/STORE-LISTINGS.md b/docs/STORE-LISTINGS.md index b120567..32304e0 100644 --- a/docs/STORE-LISTINGS.md +++ b/docs/STORE-LISTINGS.md @@ -121,7 +121,7 @@ Privacy tab: | alarms | Runs scheduled tests every 30 minutes, every 2 hours or once a day, only if you turn a schedule on in settings. Off by default. | | notifications | Shows a notice when a scheduled test finds that connection quality has dropped to Poor, only if you turn it on in settings. Off by default. | | sidePanel | Opens the history view (past results, trend chart, plan comparison and exports) in the side panel. | -| Host permission | `https://meterx-speedtest.meterx-ajithakdev.workers.dev/*` is MeterX's own test server: the extension downloads and uploads test data to it to measure speed, and reads its timing headers. The optional `https://*/*`, localhost, 127.0.0.1 and `.local` patterns are requested at runtime only when you enter your own test server in settings, and only for that one server. | +| Host permission | `https://meterx-api.ajithakdev.com/*` and `https://meterx-speedtest.meterx-ajithakdev.workers.dev/*` are MeterX's own test server (one Cloudflare Worker at two addresses; uploads use the second, which supports HTTP/3): the extension downloads and uploads test data to it to measure speed, and reads its timing headers. The optional `https://*/*`, localhost, 127.0.0.1 and `.local` patterns are requested at runtime only when you enter your own test server in settings, and only for that one server. | | Remote code | No, I am not using remote code. Leave the justification empty. | | Data usage | Tick nothing. MeterX collects none of the listed data: results stay in the browser, and the test server stores nothing. | | Privacy policy URL | `https://meterx.ajithakdev.com/privacy/` | @@ -190,7 +190,7 @@ Compatibility: Firefox only. Leave Firefox for Android unticked until it is test Notes to reviewer (used for 2027.0.1): ```text -No account needed. Click the toolbar icon and press Run test; it takes about 20 seconds. Tests run against our own server (meterx-speedtest.meterx-ajithakdev.workers.dev), which streams test data and stores nothing. The sidebar, opened from the popup, shows history and exports. +No account needed. Click the toolbar icon and press Run test; it takes about 20 seconds. Tests run against our own server (meterx-api.ajithakdev.com), which streams test data and stores nothing. The sidebar, opened from the popup, shows history and exports. Build: Linux, Node 24, npm 11. From the root of the source zip, run "npm ci && npm run package". It writes release/meterx--firefox.zip, identical to this upload. All dependencies come from npm via package-lock.json. The code is bundled with esbuild, not minified. diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 2807fef..14a193b 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -17,7 +17,9 @@ export const TEST_FILE_RE = /^(1|5|10|25)MB\.bin$/; export const MAX_UPLOAD_BYTES = 16 * 1024 * 1024; /** The default test server. Also listed in the extension's manifest host_permissions and the site's CSP; change all three together. */ -export const WORKER_URL = 'https://meterx-speedtest.meterx-ajithakdev.workers.dev'; +export const WORKER_URL = 'https://meterx-api.ajithakdev.com'; +/** The same worker on workers.dev, which keeps HTTP/3. The extension uploads there first (runner.ts) and lists it in host_permissions. */ +export const WORKER_H3_URL = 'https://meterx-speedtest.meterx-ajithakdev.workers.dev'; /** The product site, which runs a short in-page test against the worker. */ export const SITE_ORIGIN = 'https://meterx.ajithakdev.com'; diff --git a/services/worker/public/_headers b/services/worker/public/_headers new file mode 100644 index 0000000..35846a5 --- /dev/null +++ b/services/worker/public/_headers @@ -0,0 +1,5 @@ +# /ping is a static asset: free, unlimited, never counted as a Worker request. +/ping + Access-Control-Allow-Origin: * + Timing-Allow-Origin: * + Content-Type: text/plain diff --git a/services/worker/public/ping b/services/worker/public/ping new file mode 100644 index 0000000..303af67 --- /dev/null +++ b/services/worker/public/ping @@ -0,0 +1 @@ +Pong! \ No newline at end of file diff --git a/services/worker/src/index.test.ts b/services/worker/src/index.test.ts index 3b7dbc0..c2f0718 100644 --- a/services/worker/src/index.test.ts +++ b/services/worker/src/index.test.ts @@ -1,6 +1,7 @@ import { describe, it, expect } from 'vitest'; import worker, { type Env } from './index'; import { ALLOWED_SIZES_MB, MAX_UPLOAD_BYTES, VERSION } from '@meterx/shared'; +import { readFileSync } from 'node:fs'; const EXT = 'chrome-extension://abcdefghijklmnop'; const call = (path: string, init: RequestInit = {}, env: Env = {}) => @@ -52,7 +53,7 @@ describe('worker', () => { it('answers 429 when the rate limiter says no, but never for /health', async () => { const env: Env = { RATE_LIMITER: { limit: async () => ({ success: false }) } as unknown as RateLimit }; - expect((await call('/ping', {}, env)).status).toBe(429); + expect((await call('/ip', {}, env)).status).toBe(429); expect((await call('/health', {}, env)).status).toBe(200); }); @@ -60,3 +61,11 @@ describe('worker', () => { expect((await call('/nope')).status).toBe(404); }); }); + +describe('/ping static asset', () => { + it('answers Pong! with open CORS and timing headers', () => { + expect(readFileSync(new URL('../public/ping', import.meta.url), 'utf8')).toBe('Pong!'); + const rules = readFileSync(new URL('../public/_headers', import.meta.url), 'utf8'); + expect(rules).toMatch(/\n\/ping\n {2}Access-Control-Allow-Origin: \*\n {2}Timing-Allow-Origin: \*/); + }); +}); diff --git a/services/worker/src/index.ts b/services/worker/src/index.ts index 0ae5b8b..10d5701 100644 --- a/services/worker/src/index.ts +++ b/services/worker/src/index.ts @@ -1,6 +1,7 @@ /** * MeterX Cloudflare Worker: edge speed test server. * Streams generated bytes, drains uploads, stores nothing. + * /ping is a static asset in public/ (see wrangler.toml), so it never reaches this code. * @author ajithakdev (https://github.com/ajithakdev) * @license AGPL-3.0 */ @@ -119,7 +120,6 @@ export default { const dl = pathname.match(/^\/test-file\/([^/]+)$/); if (dl && method === 'GET') return handleDownload(request, dl[1]); if (pathname === '/upload' && method === 'POST') return handleUpload(request); - if (pathname === '/ping' && (method === 'HEAD' || method === 'GET')) return text(request, method === 'HEAD' ? null : 'Pong!'); if (pathname === '/health' && method === 'GET') return handleHealth(request); if (pathname === '/ip' && method === 'GET') return handleIp(request); diff --git a/services/worker/wrangler.toml b/services/worker/wrangler.toml index 4cf148e..c63a354 100644 --- a/services/worker/wrangler.toml +++ b/services/worker/wrangler.toml @@ -2,8 +2,18 @@ name = "meterx-speedtest" main = "src/index.ts" compatibility_date = "2025-03-14" +# Default test server. The zone has HTTP/3 off: Chrome uploads over QUIC stalled on Jio (2026-11-21). +# workers.dev stays on so installs from before 2027.0.3 keep working. +routes = [{ pattern = "meterx-api.ajithakdev.com", custom_domain = true }] +workers_dev = true + +# /ping is a static asset (public/ping): free, unlimited, never a Worker request, same latency in an A/B test. +# Downloads stay on the Worker: static assets added about 180 ms to each request's first byte (2026-11-21). +[assets] +directory = "./public" + # Per-IP limit so one script can't use up the free plan's daily request quota (#79). -# One test makes about 150 requests; 400 per minute leaves room for shared (CGNAT) IPs. +# One test makes about 150 requests (about 115 now that pings are static); 400 per minute leaves room for shared (CGNAT) IPs. # Counts are per Cloudflare location and approximate. [[ratelimits]] name = "RATE_LIMITER"