Compare commits
7
Commits
main
..
4c5e25ef77
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c5e25ef77 | ||
|
|
e4df415676 | ||
|
|
9e4d3fdb54 | ||
|
|
aa35625d47 | ||
|
|
0ab6418e3d | ||
|
|
4ce0814b14 | ||
|
|
e6d6815ecb |
@@ -4,3 +4,6 @@ tmp
|
||||
.DS_Store
|
||||
*.log
|
||||
.claude
|
||||
|
||||
# .git is sent so the build can stamp the version, without its config.
|
||||
.git/config
|
||||
|
||||
+41
-9
@@ -20,7 +20,10 @@ RUN make lint
|
||||
# golang:1.25-alpine (2026-02-27)
|
||||
FROM golang:1.25-alpine@sha256:f6751d823c26342f9506c03797d2527668d095b0a15f1862cddb4d927a7a4ced AS builder
|
||||
|
||||
RUN apk add --no-cache make
|
||||
# gcc and musl-dev are for make test: its race detector needs cgo, which
|
||||
# Go turns on by itself once a C compiler is present. make build still
|
||||
# sets CGO_ENABLED=0, so the binary stays static.
|
||||
RUN apk add --no-cache gcc git make musl-dev
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
@@ -37,25 +40,54 @@ RUN make test
|
||||
|
||||
# make build is a shim around backend/script/build, the one definition
|
||||
# of the build command:
|
||||
# CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.Version=... -X main.Buildarch=..."
|
||||
# CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.Version=..."
|
||||
# That script reads VERSION from the environment, so it is handed over
|
||||
# there rather than as a make variable.
|
||||
ARG VERSION=dev
|
||||
RUN VERSION="${VERSION}" make build
|
||||
#
|
||||
# The version is the VERSION build argument when one is given, otherwise
|
||||
# `git describe --tags --always` of the repo's .git: the tag on a tagged
|
||||
# commit, tag-N-gHASH on a commit after one, the short commit when no
|
||||
# tag is reachable. A version that still comes out empty, dev or unknown
|
||||
# fails the build. .git goes to /git, not /src/.git, where go build would
|
||||
# find it and record VCS details of a work tree holding only backend/.
|
||||
COPY .git /git
|
||||
ARG VERSION
|
||||
RUN version="${VERSION:-$(git --git-dir=/git describe --tags --always)}"; \
|
||||
case "$version" in ""|dev|unknown) \
|
||||
echo "version is '$version' although .git is present" >&2; \
|
||||
exit 1 ;; \
|
||||
esac; \
|
||||
VERSION="$version" make build
|
||||
|
||||
# Frontend lint stage — eslint over the JavaScript, as the lint stage
|
||||
# above lints the Go. The root make lint builds this stage alone too.
|
||||
# node:22-alpine as of 2026-02-22
|
||||
FROM node@sha256:e4bf2a82ad0a4037d28035ae71529873c069b13eb0455466ae0bc13363826e34 AS frontend-lint
|
||||
WORKDIR /app
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
COPY . .
|
||||
RUN script/frontend-lint
|
||||
|
||||
# Frontend stage
|
||||
# node:22-alpine as of 2026-02-22
|
||||
FROM node@sha256:e4bf2a82ad0a4037d28035ae71529873c069b13eb0455466ae0bc13363826e34 AS frontend
|
||||
WORKDIR /app
|
||||
|
||||
# Force BuildKit to run the frontend-lint stage before proceeding, as
|
||||
# the builder stage does with the lint stage: without this no-op copy an
|
||||
# eslint failure would not gate the image.
|
||||
COPY --from=frontend-lint /app/yarn.lock /dev/null
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
RUN apk add --no-cache git make
|
||||
COPY . .
|
||||
# make frontend-check is the frontend half of make check (test + lint +
|
||||
# fmt-check); its test step is the production yarn build, so this both
|
||||
# produces dist/ and gates the image on lint/fmt-check/test regressions.
|
||||
# This node stage has neither Go nor Docker; the lint and builder stages
|
||||
# above gate the backend half.
|
||||
# make frontend-check runs the frontend tests and format check; its test
|
||||
# step runs the unit tests, then the production yarn build, so this both
|
||||
# produces dist/ and gates the image on test and formatting regressions.
|
||||
# This node stage has neither Go nor Docker; the frontend-lint, lint and
|
||||
# builder stages above gate the rest.
|
||||
RUN make frontend-check
|
||||
|
||||
# Runtime stage
|
||||
|
||||
@@ -30,8 +30,8 @@ fmt-check:
|
||||
check:
|
||||
@script/check
|
||||
|
||||
# The frontend half of check, for Dockerfile's node build stage, which
|
||||
# has neither Go nor Docker. Use check everywhere else.
|
||||
# The frontend tests and format check, for Dockerfile's frontend stage,
|
||||
# which has neither Go nor Docker. Use check everywhere else.
|
||||
frontend-check:
|
||||
@script/frontend-check
|
||||
|
||||
|
||||
@@ -39,26 +39,31 @@ halves, so the root `make check` fails if either one is broken. We provide:
|
||||
- `script/bootstrap` — install all dependencies (the pinned node via nvm unless
|
||||
one new enough for the frontend's dependencies is installed, yarn via
|
||||
corepack, `yarn install --frozen-lockfile`, the pinned Go unless one at least
|
||||
as new as `backend/go.mod` asks for is installed, and the Go modules), linking
|
||||
what it installs itself into `~/.local/bin`, which has to be on `PATH`. It
|
||||
installs no Go linter and not Docker: `make lint` runs the linter in Docker
|
||||
as new as `backend/go.mod` asks for is installed, the Go modules, and gcc with
|
||||
the C library headers unless gcc is installed, for the race detector in
|
||||
`make test`), linking what it installs itself into `~/.local/bin`, which has
|
||||
to be on `PATH`. It installs no Go linter and not Docker: `make lint` runs
|
||||
both linters in Docker
|
||||
- `script/setup` — make a fresh clone ready for development: bootstrap plus the
|
||||
git pre-commit hook
|
||||
- `script/projectname` — print the project name (used for the Docker image tag)
|
||||
- `script/test` — run `script/frontend-test`, then the backend's Go tests, both
|
||||
within one 30-second timeout
|
||||
- `script/lint` — run `script/frontend-lint`, then golangci-lint in Docker, by
|
||||
building the lint stage of `Dockerfile` without the cache
|
||||
- `script/test` — run `script/frontend-test`, then the backend's Go tests, each
|
||||
under its own 30-second timeout
|
||||
- `script/lint` — run eslint, then golangci-lint, both in Docker, by building
|
||||
the `frontend-lint` and `lint` stages of `Dockerfile` without the cache
|
||||
- `script/fmt` — format all files (writes): prettier, then gofmt over `backend/`
|
||||
- `script/fmt-check` — check formatting (read-only): prettier, then gofmt
|
||||
- `script/check` — run test, lint, and fmt-check
|
||||
- `script/frontend-test` — run the production build as the frontend's test (no
|
||||
unit tests yet)
|
||||
- `script/frontend-lint` — run prettier in check mode
|
||||
- `script/frontend-test` — run the unit tests in `test/unit/` with Node's
|
||||
built-in test runner, then the production build
|
||||
- `script/frontend-lint` — run eslint with the rules in `eslint.config.js`; it
|
||||
runs inside the `frontend-lint` stage of `Dockerfile`, which `make lint`
|
||||
builds
|
||||
- `script/frontend-fmt` — format everything prettier understands (writes)
|
||||
- `script/frontend-fmt-check` — check prettier formatting (read-only)
|
||||
- `script/frontend-check` — the frontend half of `script/check`, for
|
||||
`Dockerfile`, whose node build stage has neither Go nor Docker
|
||||
- `script/frontend-check` — run `script/frontend-test` and
|
||||
`script/frontend-fmt-check`, for the frontend stage of `Dockerfile`, which has
|
||||
neither Go nor Docker
|
||||
- `script/frontend-viewport-test` — responsive-layout verification of the built
|
||||
frontend in a containerised headless Chrome (see
|
||||
[test/viewport/README.md](test/viewport/README.md)). Not part of
|
||||
@@ -136,8 +141,14 @@ Local hosts are tracked separately from WAN stats.
|
||||
### Latency measurement
|
||||
|
||||
HEAD requests with `mode: 'no-cors'` and `cache: 'no-store'`, timed with
|
||||
`performance.now()`. 1-second timeout; anything over 1000ms is clamped to
|
||||
unreachable. IPv4 only.
|
||||
`performance.now()`. Each check times out after 80% of the refresh interval (24
|
||||
seconds at 30 seconds) and is then recorded as a timeout, so a round's checks
|
||||
have all finished before the next round is due. When no WAN host answers, a
|
||||
recovery probe checks 4 random WAN hosts every half second, giving up the checks
|
||||
it started half a second before. As soon as one answers, a new round starts at
|
||||
once, as it does after an interval change. A round started early gives up the
|
||||
last round's checks if they are still waiting, and that round records nothing,
|
||||
so rounds never overlap. IPv4 only.
|
||||
|
||||
### Color coding
|
||||
|
||||
@@ -212,7 +223,7 @@ What the [upaas](https://git.eeqj.de/sneak/upaas) app for netwatch needs:
|
||||
- `REPORTS_PER_MINUTE`, default `60`: reports each client address may send a
|
||||
minute
|
||||
- `DATA_DIR_MAX_BYTES`, default `1073741824` (1 GiB): the most room the
|
||||
report files may take
|
||||
report files may take; the oldest are deleted to stay under it
|
||||
- `CORS_ALLOWED_ORIGINS`, default empty: other origins whose pages may call
|
||||
the API
|
||||
- `DEBUG`, default `false`: debug logging
|
||||
@@ -252,7 +263,6 @@ properties.
|
||||
## TODO
|
||||
|
||||
- Add unit tests
|
||||
- Add eslint for JS linting (currently lint target runs prettier only)
|
||||
- Add configurable host list (environment variable or config file)
|
||||
- Add latency history export (CSV/JSON)
|
||||
- Add notification/alert when status changes to DEGRADED
|
||||
|
||||
@@ -23,6 +23,51 @@ latest run passes.
|
||||
|
||||
# Completed Steps
|
||||
|
||||
- 2026-10-03: the frontend has a real linter (issue #47, and item 2 of issue
|
||||
#28): `eslint` with its recommended rules, set in `eslint.config.js`, runs in
|
||||
a new `frontend-lint` stage of `Dockerfile`, which the frontend stage waits
|
||||
on, as the builder stage waits on the Go `lint` stage. `script/lint` builds
|
||||
both stages without the cache and runs no linter on the host.
|
||||
`script/frontend-lint` runs eslint where it used to repeat the prettier check
|
||||
that `script/fmt-check` runs on the host, and `script/frontend-check`, run by
|
||||
the frontend stage, is now the tests and the format check. `script/bootstrap`
|
||||
wants node 22.13.0 or newer, as eslint 10 does
|
||||
- 2026-10-03: `DATA_DIR_MAX_BYTES` is now how much of the report files is kept
|
||||
(issue #54): when a report would take them past it, the oldest report files
|
||||
are deleted to make room, each deletion logged, and at start files already
|
||||
past it are deleted the same way. A file still being written is never deleted.
|
||||
A report is refused with 507 only when the reports waiting to be written fill
|
||||
the cap on their own, and then no file is deleted. The reports of a failed
|
||||
write stop counting, and the part of its file written is removed. A file that
|
||||
cannot be deleted still counts until the next start; one already deleted by
|
||||
hand counts as freed
|
||||
- 2026-10-03: `backend/script/lint` says what went wrong with its
|
||||
`.golangci.yml` check (issue #34). On a hash mismatch it says to compare the
|
||||
file with the org standard: if they differ, restore the org standard; if they
|
||||
are the same, the org standard changed, so update `GOLANGCI_CONFIG_SHA256` in
|
||||
that script. It used to say only to restore the file, which loops once the org
|
||||
standard itself has moved. A missing `.golangci.yml`, and a `sha256sum` that
|
||||
is missing or prints no hash, each get their own message instead of being
|
||||
reported as a mismatch; every one still fails the lint
|
||||
- 2026-10-03: the Go tests run with the race detector and coverage (issue #88):
|
||||
`backend/script/test` runs `go test -timeout 30s -race -cover ./...` and, if
|
||||
that fails, runs it again with `-v` and fails. Go's `-timeout` bounds the
|
||||
tests, not their compile; the root `script/test` no longer puts one 30-second
|
||||
timeout around both halves, which a cold Go build cache could use up on
|
||||
compiling alone. The race detector needs a C compiler: the builder stage of
|
||||
`Dockerfile` has gcc and musl-dev, and `script/bootstrap` installs gcc, with
|
||||
the C library headers on apt and apk, when gcc is missing; the binary is still
|
||||
built with `CGO_ENABLED=0`. New tests cover the health check's answer, a valid
|
||||
report's answer, a report file's exact contents, and the flush when the buffer
|
||||
reaches 10 MiB; the handlers' `TestImport` stub is gone
|
||||
- 2026-10-03: each target check times out after 80% of the refresh interval
|
||||
(issue #78), 24 seconds at 30 seconds, where it was capped at 3 seconds. A
|
||||
round started early, after an interval change or when the recovery probe finds
|
||||
a target answering, gives up the last round's checks if they are still
|
||||
waiting, so rounds never overlap; the recovery probe gives up its own checks
|
||||
after half a second. The frontend has its first unit tests, run by
|
||||
`script/frontend-test` with Node's built-in test runner; for them,
|
||||
`index.html` now links `src/styles.css`, which `src/main.js` used to import
|
||||
- 2026-09-29: the container sets up its own data directory (issue #75):
|
||||
`bin/entrypoint.sh`, still as root, creates `DATA_DIR` if missing and gives it
|
||||
and `/data` to the `netwatch` user with mode 750 before starting the backend
|
||||
|
||||
+22
-13
@@ -32,10 +32,13 @@ pattern as the repo root: the targets in `backend/Makefile` are thin shims over
|
||||
`test`, `fmt` and `fmt-check`:
|
||||
|
||||
- `script/build` — compile the static `netwatch-server` binary with its version
|
||||
and architecture stamped in. The version is `VERSION` from the environment;
|
||||
stamped in. The version is `VERSION` from the environment;
|
||||
when that is unset or empty, it falls back to `git describe` inside a git
|
||||
checkout, then to `dev`
|
||||
- `script/test` — run the Go tests under a 30-second timeout
|
||||
- `script/test` — run the Go tests with the race detector and coverage. Go's
|
||||
`-timeout 30s` bounds the tests, not their compile. If they fail, they run
|
||||
again with `-v` for the details, and the script fails. The race detector needs
|
||||
a C compiler
|
||||
- `script/lint` — check `.golangci.yml` against its pinned sha256, then run
|
||||
golangci-lint. It runs inside the golangci-lint image of the lint stage of
|
||||
the root `Dockerfile`; from a checkout, run `make lint` at the repo root,
|
||||
@@ -80,7 +83,7 @@ Internal packages in `internal/` follow standard Go project layout:
|
||||
| `BIND_ADDRESS` | empty | IP address to listen on; empty listens on every interface |
|
||||
| `PORT` | `8080` | HTTP listen port |
|
||||
| `DATA_DIR` | `./data/reports` | Directory for compressed reports |
|
||||
| `DATA_DIR_MAX_BYTES` | `1073741824` (1 GiB) | Largest total size of the report files in `DATA_DIR`; see [Report limits](#report-limits) |
|
||||
| `DATA_DIR_MAX_BYTES` | `1073741824` (1 GiB) | Most bytes of report files kept in `DATA_DIR`, oldest deleted first; see [Report limits](#report-limits) |
|
||||
| `DEBUG` | `false` | Enable debug logging |
|
||||
| `TRUSTED_PROXIES` | loopback + RFC1918 | Comma-separated CIDRs whose `X-Forwarded-For` / `X-Real-IP` headers are trusted for client IP resolution |
|
||||
| `REPORTS_PER_MINUTE` | `60` | Reports each client address may send a minute; see [Report limits](#report-limits) |
|
||||
@@ -125,10 +128,11 @@ Reports are written as `reports-<timestamp>-<number>.jsonl.zst` files in
|
||||
`DATA_DIR`. The timestamp is in UTC to the millisecond, so the names sort by
|
||||
time. The number starts at 1 when the server starts and goes up by one for each
|
||||
file the server starts to write, so two files written in the same millisecond
|
||||
still get different names. A failed write uses up its number, leaving a gap in
|
||||
the numbers if the file could not be created and otherwise a file under that
|
||||
number that may be incomplete. Each file contains one JSON object per line,
|
||||
compressed with zstd. Files are created with `O_EXCL` to prevent overwrites.
|
||||
still get different names. A failed write uses up its number and leaves a gap in
|
||||
the numbers: its file, if it was created, is removed. The file stays, counted
|
||||
toward `DATA_DIR_MAX_BYTES` from the next start, only if removing it fails too.
|
||||
Each file contains one JSON object per line, compressed with zstd. Files are
|
||||
created with `O_EXCL` to prevent overwrites.
|
||||
|
||||
### Report limits
|
||||
|
||||
@@ -148,11 +152,17 @@ credentials, so it is bounded instead. Both refusals below answer with the same
|
||||
`X-RateLimit-Reset` headers.
|
||||
- **Size cap.** The report files in `DATA_DIR` may total at most
|
||||
`DATA_DIR_MAX_BYTES`, counting the files already there at start. Reports
|
||||
waiting in memory count at their uncompressed size until they are written, so
|
||||
a report that would take the total past the cap is refused with 507, and
|
||||
nothing of it is stored. Deleting report files frees room only at the next
|
||||
start, when the files are counted again. The default of 1 GiB is small enough
|
||||
for any host; set it to the space you can give `DATA_DIR`.
|
||||
waiting in memory count at their uncompressed size until they are written;
|
||||
those lost to a failed write stop counting, and the part of its file written
|
||||
is removed. When a report would take the total past the cap, the oldest report
|
||||
files are deleted to make room, and each deletion is logged with the file's
|
||||
name and size; a file still being written is never deleted. A report is
|
||||
refused with 507, and nothing of it is stored, only when the reports waiting
|
||||
to be written fill the cap on their own, and then no file is deleted. At
|
||||
start, report files past the cap, as after lowering it, are deleted the same
|
||||
way. So the cap is how much of the newest reports is kept: the default of 1
|
||||
GiB is small enough for any host; set it to the space you can give
|
||||
`DATA_DIR`.
|
||||
|
||||
### CORS
|
||||
|
||||
@@ -170,7 +180,6 @@ starting, with an error naming `CORS_ALLOWED_ORIGINS`.
|
||||
- Add integration test that POSTs a report and verifies the compressed output
|
||||
- Add report decompression/query endpoint
|
||||
- Add metrics (Prometheus) for buffer size, flush count, report count
|
||||
- Add retention policy to prune old report files
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
var (
|
||||
Appname = "netwatch-server"
|
||||
Version string
|
||||
Buildarch string
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -40,7 +39,6 @@ func main() {
|
||||
|
||||
globals.Appname = Appname
|
||||
globals.Version = Version
|
||||
globals.Buildarch = Buildarch
|
||||
|
||||
fx.New(
|
||||
fx.Provide(
|
||||
|
||||
@@ -10,22 +10,18 @@ var (
|
||||
Appname string
|
||||
// Version is the git version tag.
|
||||
Version string
|
||||
// Buildarch is the build architecture.
|
||||
Buildarch string
|
||||
)
|
||||
|
||||
// Globals holds build-time metadata for the application.
|
||||
type Globals struct {
|
||||
Appname string
|
||||
Version string
|
||||
Buildarch string
|
||||
}
|
||||
|
||||
// New creates a Globals instance from package-level variables.
|
||||
func New(_ fx.Lifecycle) (*Globals, error) {
|
||||
return &Globals{
|
||||
Appname: Appname,
|
||||
Buildarch: Buildarch,
|
||||
Version: Version,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
_ "sneak.berlin/go/netwatch/internal/handlers"
|
||||
)
|
||||
|
||||
func TestImport(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Compilation check — verifies the package parses
|
||||
// and all imports resolve.
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"maps"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"sneak.berlin/go/netwatch/internal/globals"
|
||||
"sneak.berlin/go/netwatch/internal/handlers"
|
||||
"sneak.berlin/go/netwatch/internal/healthcheck"
|
||||
"sneak.berlin/go/netwatch/internal/logger"
|
||||
|
||||
"go.uber.org/fx/fxtest"
|
||||
)
|
||||
|
||||
// newStartedHandlers builds Handlers with a real health check for the
|
||||
// server named in g, and starts them, which records the time the
|
||||
// uptime counts from.
|
||||
func newStartedHandlers(t *testing.T, g *globals.Globals) *handlers.Handlers {
|
||||
t.Helper()
|
||||
|
||||
lc := fxtest.NewLifecycle(t)
|
||||
|
||||
log, err := logger.New(lc, logger.Params{Globals: g})
|
||||
if err != nil {
|
||||
t.Fatalf("logger: %v", err)
|
||||
}
|
||||
|
||||
hc, err := healthcheck.New(lc,
|
||||
healthcheck.Params{Globals: g, Logger: log})
|
||||
if err != nil {
|
||||
t.Fatalf("health check: %v", err)
|
||||
}
|
||||
|
||||
h, err := handlers.New(lc,
|
||||
handlers.Params{Globals: g, Healthcheck: hc, Logger: log})
|
||||
if err != nil {
|
||||
t.Fatalf("handlers: %v", err)
|
||||
}
|
||||
|
||||
lc.RequireStart()
|
||||
t.Cleanup(lc.RequireStop)
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
// TestHandleHealthCheck checks the health check's answer: 200, a JSON
|
||||
// content type, and a JSON object with exactly the fields of
|
||||
// healthcheck.Response, carrying this server's name and version and
|
||||
// an uptime counted from its start.
|
||||
func TestHandleHealthCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
g := &globals.Globals{Appname: "netwatch-server", Version: "v1.2.3"}
|
||||
h := newStartedHandlers(t, g)
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequestWithContext(t.Context(),
|
||||
http.MethodGet, "/.well-known/healthcheck", http.NoBody)
|
||||
|
||||
h.HandleHealthCheck().ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
|
||||
}
|
||||
|
||||
contentType := rec.Header().Get("Content-Type")
|
||||
if contentType != "application/json; charset=utf-8" {
|
||||
t.Errorf("Content-Type = %q, want %q",
|
||||
contentType, "application/json; charset=utf-8")
|
||||
}
|
||||
|
||||
var body map[string]any
|
||||
|
||||
err := json.Unmarshal(rec.Body.Bytes(), &body)
|
||||
if err != nil {
|
||||
t.Fatalf("body not a JSON object: %v (%q)", err, rec.Body.String())
|
||||
}
|
||||
|
||||
fields := []string{
|
||||
"appname", "now", "status", "uptimeHuman", "uptimeSeconds", "version",
|
||||
}
|
||||
if got := slices.Sorted(maps.Keys(body)); !slices.Equal(got, fields) {
|
||||
t.Fatalf("fields = %v, want %v", got, fields)
|
||||
}
|
||||
|
||||
for field, want := range map[string]string{
|
||||
"appname": g.Appname, "status": "ok", "version": g.Version,
|
||||
} {
|
||||
if body[field] != want {
|
||||
t.Errorf("%s = %v, want %q", field, body[field], want)
|
||||
}
|
||||
}
|
||||
|
||||
now, _ := body["now"].(string)
|
||||
|
||||
at, err := time.Parse(time.RFC3339Nano, now)
|
||||
if err != nil || time.Since(at).Abs() > time.Minute {
|
||||
t.Errorf("now = %q, want the current time in RFC 3339 (%v)", now, err)
|
||||
}
|
||||
|
||||
// Started just now, so the uptime is well under a minute.
|
||||
human, _ := body["uptimeHuman"].(string)
|
||||
|
||||
uptime, err := time.ParseDuration(human)
|
||||
if err != nil || uptime > time.Minute {
|
||||
t.Errorf("uptimeHuman = %q, want a duration under a minute (%v)",
|
||||
human, err)
|
||||
}
|
||||
|
||||
seconds, ok := body["uptimeSeconds"].(float64)
|
||||
if !ok || seconds < 0 || seconds > time.Minute.Seconds() {
|
||||
t.Errorf("uptimeSeconds = %v, want a number of seconds under a minute",
|
||||
body["uptimeSeconds"])
|
||||
}
|
||||
}
|
||||
@@ -86,11 +86,12 @@ func (s *Handlers) decodeErrorStatus(err error) int {
|
||||
}
|
||||
|
||||
// appendErrorStatus logs a failure to store a report and returns
|
||||
// the status to send: 507 when the report files are at their size
|
||||
// cap, otherwise 500.
|
||||
// the status to send: 507 when the reports waiting to be written fill
|
||||
// the size cap, otherwise 500.
|
||||
func (s *Handlers) appendErrorStatus(err error) int {
|
||||
if errors.Is(err, reportbuf.ErrFull) {
|
||||
s.log.Warn("report refused: report files at their size cap")
|
||||
s.log.Warn("report refused: " +
|
||||
"reports waiting to be written fill the size cap")
|
||||
|
||||
return http.StatusInsufficientStorage
|
||||
}
|
||||
|
||||
@@ -46,6 +46,63 @@ func decodeStatus(t *testing.T, body []byte) string {
|
||||
return resp.Status
|
||||
}
|
||||
|
||||
// TestHandleReportAcceptsValidReports checks the answer to a valid
|
||||
// report, one with no hosts and one shaped as the frontend sends them:
|
||||
// 200 and {"status":"ok"} as JSON.
|
||||
func TestHandleReportAcceptsValidReports(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
body string
|
||||
}{
|
||||
{
|
||||
name: "no hosts",
|
||||
body: `{"clientId":"c1","geo":null,"hosts":[],` +
|
||||
`"timestamp":"2026-10-03T12:00:00.000Z"}`,
|
||||
},
|
||||
{
|
||||
name: "a host with a latency and an error sample",
|
||||
body: `{"clientId":"c1","geo":null,"hosts":[{` +
|
||||
`"name":"Example","url":"https://example.com/",` +
|
||||
`"status":"error","history":[` +
|
||||
`{"t":1790000000000,"latency":42,"error":null},` +
|
||||
`{"t":1790000003000,"latency":null,"error":"timeout"}]}],` +
|
||||
`"timestamp":"2026-10-03T12:00:00.000Z"}`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
h := newTestHandlers(stubAppender{}, io.Discard)
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequestWithContext(t.Context(),
|
||||
http.MethodPost, "/api/v1/reports",
|
||||
strings.NewReader(tt.body),
|
||||
)
|
||||
|
||||
h.HandleReport().ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
|
||||
}
|
||||
|
||||
contentType := rec.Header().Get("Content-Type")
|
||||
if contentType != "application/json; charset=utf-8" {
|
||||
t.Errorf("Content-Type = %q, want %q",
|
||||
contentType, "application/json; charset=utf-8")
|
||||
}
|
||||
|
||||
if got := rec.Body.String(); got != "{\"status\":\"ok\"}\n" {
|
||||
t.Errorf("body = %q, want %q", got, "{\"status\":\"ok\"}\n")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleReportStorageFailureIsNon2xx(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -68,9 +125,9 @@ func TestHandleReportStorageFailureIsNon2xx(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleReportFullIs507 checks the answer when the report files
|
||||
// are at their size cap: 507 and the usual error body, which tells
|
||||
// the client nothing more.
|
||||
// TestHandleReportFullIs507 checks the answer when the reports waiting
|
||||
// to be written fill the size cap: 507 and the usual error body, which
|
||||
// tells the client nothing more.
|
||||
func TestHandleReportFullIs507(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package logger
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"sneak.berlin/go/netwatch/internal/globals"
|
||||
|
||||
@@ -95,6 +96,6 @@ func (l *Logger) Identify() {
|
||||
l.log.Info("starting",
|
||||
"appname", l.params.Globals.Appname,
|
||||
"version", l.params.Globals.Version,
|
||||
"buildarch", l.params.Globals.Buildarch,
|
||||
"arch", runtime.GOARCH,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package reportbuf
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// FlushSizeThreshold exposes the buffer size at which Append starts
|
||||
// writing a report file to the external tests.
|
||||
const FlushSizeThreshold = flushSizeThreshold
|
||||
|
||||
// Flush writes the buffered reports to a file now, as the periodic
|
||||
// flush does, so tests need not wait a minute for it.
|
||||
@@ -13,3 +20,10 @@ func (b *Buffer) Flush() error {
|
||||
func (b *Buffer) StopClock(at time.Time) {
|
||||
b.now = func() time.Time { return at }
|
||||
}
|
||||
|
||||
// OnFileCreated makes the buffer call fn with each report file it
|
||||
// writes from now on, once the file is created and before anything is
|
||||
// written to it.
|
||||
func (b *Buffer) OnFileCreated(fn func(f *os.File)) {
|
||||
b.fileCreated = fn
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Package reportbuf accumulates telemetry reports in memory
|
||||
// and periodically flushes them to zstd-compressed JSONL files.
|
||||
// and periodically flushes them to zstd-compressed JSONL files,
|
||||
// deleting the oldest files to keep them under a size cap.
|
||||
package reportbuf
|
||||
|
||||
import (
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -37,9 +39,10 @@ const (
|
||||
fileSuffix = ".jsonl.zst"
|
||||
)
|
||||
|
||||
// ErrFull is returned by Append when storing the report would
|
||||
// take the report files past the configured maximum size.
|
||||
var ErrFull = errors.New("report files at their size cap")
|
||||
// ErrFull is returned by Append when the reports waiting to be
|
||||
// written leave no room for the report under the configured maximum
|
||||
// size, however many report files are deleted.
|
||||
var ErrFull = errors.New("reports waiting to be written fill the size cap")
|
||||
|
||||
// Params defines the dependencies for Buffer.
|
||||
type Params struct {
|
||||
@@ -49,12 +52,31 @@ type Params struct {
|
||||
Logger *logger.Logger
|
||||
}
|
||||
|
||||
// reportFile is a report file that may be deleted to make room, with
|
||||
// the size it counts for in usedBytes.
|
||||
type reportFile struct {
|
||||
name string
|
||||
size int64
|
||||
}
|
||||
|
||||
// Buffer accumulates JSON lines in memory and flushes them
|
||||
// to zstd-compressed files on disk.
|
||||
type Buffer struct {
|
||||
buf bytes.Buffer
|
||||
dataDir string
|
||||
done chan struct{}
|
||||
// fileCreated is called with each report file once it is
|
||||
// created, before anything is written to it: it does nothing,
|
||||
// except in tests that hold the write open or make it fail.
|
||||
fileCreated func(f *os.File)
|
||||
// files are the report files that may be deleted to make room,
|
||||
// in name order, which is oldest first: those in dataDir at
|
||||
// start, and each one this buffer writes, put in at its place by
|
||||
// name once it is complete, even when an older file's write
|
||||
// completes after a newer one's. A file still being written is
|
||||
// not among them. filesBytes is their total size.
|
||||
files []reportFile
|
||||
filesBytes int64
|
||||
log *slog.Logger
|
||||
maxBytes int64
|
||||
mu sync.Mutex
|
||||
@@ -66,8 +88,8 @@ type Buffer struct {
|
||||
seq atomic.Uint64
|
||||
stopOnce sync.Once
|
||||
// usedBytes is what Append checks against maxBytes: the size
|
||||
// of the report files in dataDir, plus the reports not yet
|
||||
// written to one at their uncompressed size.
|
||||
// of the report files in dataDir, plus the reports waiting to
|
||||
// be written to one at their uncompressed size.
|
||||
usedBytes int64
|
||||
}
|
||||
|
||||
@@ -85,6 +107,7 @@ func New(
|
||||
b := &Buffer{
|
||||
dataDir: dir,
|
||||
done: make(chan struct{}),
|
||||
fileCreated: func(*os.File) {},
|
||||
log: params.Logger.Get(),
|
||||
maxBytes: params.Config.DataDirMaxBytes,
|
||||
now: time.Now,
|
||||
@@ -97,12 +120,28 @@ func New(
|
||||
return fmt.Errorf("create data dir: %w", err)
|
||||
}
|
||||
|
||||
// Report files left by earlier runs count too.
|
||||
b.usedBytes, err = reportFilesSize(b.dataDir)
|
||||
// Report files left by earlier runs count too, and are
|
||||
// the first to be deleted to make room.
|
||||
files, err := reportFiles(b.dataDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.mu.Lock()
|
||||
|
||||
b.files = files
|
||||
for _, f := range files {
|
||||
b.filesBytes += f.size
|
||||
}
|
||||
|
||||
b.usedBytes = b.filesBytes
|
||||
|
||||
// The files may be past the cap, if it was lowered since
|
||||
// the last run.
|
||||
b.deleteOldestFiles(0)
|
||||
|
||||
b.mu.Unlock()
|
||||
|
||||
go b.flushLoop()
|
||||
|
||||
return nil
|
||||
@@ -128,9 +167,10 @@ func New(
|
||||
}
|
||||
|
||||
// Append marshals v as a single JSON line and appends it to
|
||||
// the buffer. It stores nothing and returns ErrFull if the line
|
||||
// would take usedBytes past maxBytes. If the buffer reaches the
|
||||
// size threshold, it is drained and written to disk
|
||||
// the buffer. If the line would take usedBytes past maxBytes, the
|
||||
// oldest report files are deleted to make room; it stores nothing
|
||||
// and returns ErrFull if that cannot make room. If the buffer
|
||||
// reaches the size threshold, it is drained and written to disk
|
||||
// asynchronously.
|
||||
func (b *Buffer) Append(v any) error {
|
||||
line, err := json.Marshal(v)
|
||||
@@ -142,6 +182,8 @@ func (b *Buffer) Append(v any) error {
|
||||
|
||||
b.mu.Lock()
|
||||
|
||||
b.deleteOldestFiles(lineBytes)
|
||||
|
||||
if b.usedBytes+lineBytes > b.maxBytes {
|
||||
b.mu.Unlock()
|
||||
|
||||
@@ -171,6 +213,37 @@ func (b *Buffer) Append(v any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// deleteOldestFiles deletes report files, oldest first, until n more
|
||||
// bytes fit under maxBytes. It deletes none when the reports waiting
|
||||
// to be written leave no room for n even with every file gone, since
|
||||
// that would lose the files for nothing. The caller must hold b.mu.
|
||||
func (b *Buffer) deleteOldestFiles(n int64) {
|
||||
for b.usedBytes+n > b.maxBytes && len(b.files) > 0 {
|
||||
if b.usedBytes-b.filesBytes+n > b.maxBytes {
|
||||
return
|
||||
}
|
||||
|
||||
f := b.files[0]
|
||||
b.files = b.files[1:]
|
||||
b.filesBytes -= f.size
|
||||
|
||||
// A file already gone, deleted by hand, has freed its room too.
|
||||
err := os.Remove(filepath.Join(b.dataDir, f.name))
|
||||
if err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
// The file is still there, so it still counts. It is
|
||||
// not tried again until the next start.
|
||||
b.log.Error("delete report file failed",
|
||||
"file", f.name, "error", err)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
b.usedBytes -= f.size
|
||||
b.log.Info("deleted report file to make room",
|
||||
"file", f.name, "bytes", f.size)
|
||||
}
|
||||
}
|
||||
|
||||
// flushLoop runs a ticker that periodically flushes buffered
|
||||
// data to disk until the done channel is closed.
|
||||
func (b *Buffer) flushLoop() {
|
||||
@@ -217,15 +290,48 @@ func (b *Buffer) drainBuf() []byte {
|
||||
return data
|
||||
}
|
||||
|
||||
// writeFile creates a timestamped zstd-compressed JSONL file
|
||||
// in the data directory.
|
||||
// writeFile writes data, reports drained from the buffer, to a new
|
||||
// timestamped zstd-compressed JSONL file in the data directory.
|
||||
func (b *Buffer) writeFile(data []byte) error {
|
||||
// The timestamp comes first, so the names sort by time; the number
|
||||
// after it tells apart files named in the same millisecond.
|
||||
ts := b.now().UTC().Format("2006-01-02T15-04-05.000Z")
|
||||
name := fmt.Sprintf("%s%s-%d%s", filePrefix, ts, b.seq.Add(1), fileSuffix)
|
||||
path := filepath.Join(b.dataDir, name)
|
||||
|
||||
size, err := b.createFile(filepath.Join(b.dataDir, name), data)
|
||||
|
||||
// The reports no longer wait to be written, so they stop counting
|
||||
// at their uncompressed size. If the write failed they are lost;
|
||||
// otherwise they count as the file, which from here on may be
|
||||
// deleted to make room.
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
b.usedBytes -= int64(len(data))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.usedBytes += size
|
||||
b.filesBytes += size
|
||||
|
||||
// At its place by name, not at the end: another write, of a newer
|
||||
// file, may have completed while this one was being written.
|
||||
i, _ := slices.BinarySearchFunc(b.files, name,
|
||||
func(f reportFile, target string) int {
|
||||
return strings.Compare(f.name, target)
|
||||
})
|
||||
b.files = slices.Insert(b.files, i, reportFile{name: name, size: size})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// createFile creates the file at path holding data compressed with
|
||||
// zstd, and returns its size. If the write fails once the file is
|
||||
// created, it removes the file, so that a failed write leaves nothing
|
||||
// behind to take room.
|
||||
func (b *Buffer) createFile(path string, data []byte) (int64, error) {
|
||||
// path is built from the operator-supplied dataDir plus a
|
||||
// generated timestamp and number, so it carries no external input.
|
||||
f, err := os.OpenFile( //nolint:gosec // see comment above
|
||||
@@ -234,61 +340,65 @@ func (b *Buffer) writeFile(data []byte) error {
|
||||
filePerms,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create report file: %w", err)
|
||||
return 0, fmt.Errorf("create report file: %w", err)
|
||||
}
|
||||
|
||||
// Closes the file on the early returns below. The success
|
||||
// path closes it explicitly to check the error; closing it
|
||||
// a second time here is harmless.
|
||||
defer func() { _ = f.Close() }()
|
||||
b.fileCreated(f)
|
||||
|
||||
size, err := writeCompressed(f, data)
|
||||
if err != nil {
|
||||
_ = f.Close()
|
||||
|
||||
return 0, errors.Join(err, os.Remove(path))
|
||||
}
|
||||
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("close report file: %w", err)
|
||||
|
||||
return 0, errors.Join(err, os.Remove(path))
|
||||
}
|
||||
|
||||
return size, nil
|
||||
}
|
||||
|
||||
// writeCompressed writes data to f compressed with zstd, and returns
|
||||
// the size of f.
|
||||
func writeCompressed(f *os.File, data []byte) (int64, error) {
|
||||
enc, err := zstd.NewWriter(f)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create zstd encoder: %w", err)
|
||||
return 0, fmt.Errorf("create zstd encoder: %w", err)
|
||||
}
|
||||
|
||||
_, err = enc.Write(data)
|
||||
if err != nil {
|
||||
_ = enc.Close()
|
||||
|
||||
return fmt.Errorf("write compressed data: %w", err)
|
||||
return 0, fmt.Errorf("write compressed data: %w", err)
|
||||
}
|
||||
|
||||
err = enc.Close()
|
||||
if err != nil {
|
||||
return fmt.Errorf("close zstd encoder: %w", err)
|
||||
return 0, fmt.Errorf("close zstd encoder: %w", err)
|
||||
}
|
||||
|
||||
info, err := f.Stat()
|
||||
if err != nil {
|
||||
return fmt.Errorf("stat report file: %w", err)
|
||||
return 0, fmt.Errorf("stat report file: %w", err)
|
||||
}
|
||||
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
return fmt.Errorf("close report file: %w", err)
|
||||
}
|
||||
|
||||
// The reports counted at their uncompressed size while they
|
||||
// waited; now they count as the file. After a failed write they
|
||||
// stay counted as they were, which errs toward refusing reports
|
||||
// early rather than letting the files pass the cap.
|
||||
b.mu.Lock()
|
||||
b.usedBytes += info.Size() - int64(len(data))
|
||||
b.mu.Unlock()
|
||||
|
||||
return nil
|
||||
return info.Size(), nil
|
||||
}
|
||||
|
||||
// reportFilesSize returns the total size of the report files in
|
||||
// dir.
|
||||
func reportFilesSize(dir string) (int64, error) {
|
||||
// reportFiles returns the report files in dir, oldest first:
|
||||
// os.ReadDir sorts them by name, and the names sort by time.
|
||||
func reportFiles(dir string) ([]reportFile, error) {
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("read data dir: %w", err)
|
||||
return nil, fmt.Errorf("read data dir: %w", err)
|
||||
}
|
||||
|
||||
var total int64
|
||||
files := make([]reportFile, 0, len(entries))
|
||||
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
@@ -299,11 +409,11 @@ func reportFilesSize(dir string) (int64, error) {
|
||||
|
||||
info, err := entry.Info()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("stat report file: %w", err)
|
||||
return nil, fmt.Errorf("stat report file: %w", err)
|
||||
}
|
||||
|
||||
total += info.Size()
|
||||
files = append(files, reportFile{name: name, size: info.Size()})
|
||||
}
|
||||
|
||||
return total, nil
|
||||
return files, nil
|
||||
}
|
||||
|
||||
@@ -139,11 +139,19 @@ func lineBytes(t *testing.T, report any) int {
|
||||
return len(line) + 1
|
||||
}
|
||||
|
||||
// TestAppendPastCapIsRefused fills the cap with a report not yet
|
||||
// written. The next report is refused, and the report file already in
|
||||
// DATA_DIR is kept: it is smaller than a report, so deleting it could
|
||||
// not make room.
|
||||
func TestAppendPastCapIsRefused(t *testing.T) {
|
||||
report := map[string]string{"id": "cap"}
|
||||
dir := t.TempDir()
|
||||
earlier := reportFilePath(dir, 1)
|
||||
|
||||
t.Setenv("DATA_DIR", t.TempDir())
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(lineBytes(t, report)))
|
||||
writeBytes(t, earlier, 1)
|
||||
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(1+lineBytes(t, report)))
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
@@ -156,24 +164,38 @@ func TestAppendPastCapIsRefused(t *testing.T) {
|
||||
if !errors.Is(err, reportbuf.ErrFull) {
|
||||
t.Fatalf("report past the cap: error = %v, want ErrFull", err)
|
||||
}
|
||||
|
||||
if !exists(t, earlier) {
|
||||
t.Fatal("report file deleted, though that could not make room")
|
||||
}
|
||||
}
|
||||
|
||||
// TestCapCountsReportFilesAlreadyInDataDir starts on a data
|
||||
// directory holding a report file from an earlier run, and a file
|
||||
// that is not a report, which must not count.
|
||||
func TestCapCountsReportFilesAlreadyInDataDir(t *testing.T) {
|
||||
const earlierBytes = 100
|
||||
// TestOldestReportFileDeletedFirst starts on a data directory holding
|
||||
// report files from an earlier run, and a file that is not a report,
|
||||
// which neither counts nor is ever deleted. Nothing is deleted while
|
||||
// there is room; then only the oldest report file is.
|
||||
func TestOldestReportFileDeletedFirst(t *testing.T) {
|
||||
const fileBytes = 100
|
||||
|
||||
report := map[string]string{"id": "cap"}
|
||||
report := map[string]string{"id": "oldest"}
|
||||
dir := t.TempDir()
|
||||
oldest := reportFilePath(dir, 1)
|
||||
kept := []string{
|
||||
reportFilePath(dir, 2),
|
||||
reportFilePath(dir, 3),
|
||||
filepath.Join(dir, "notes.txt"),
|
||||
}
|
||||
|
||||
writeBytes(t, filepath.Join(dir, "reports-2026-01-01T00-00-00.000Z.jsonl.zst"),
|
||||
earlierBytes)
|
||||
writeBytes(t, filepath.Join(dir, "notes.txt"), 10*earlierBytes)
|
||||
writeBytes(t, oldest, fileBytes)
|
||||
|
||||
for _, path := range kept {
|
||||
writeBytes(t, path, fileBytes)
|
||||
}
|
||||
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
// Room for the three report files and one report.
|
||||
t.Setenv("DATA_DIR_MAX_BYTES",
|
||||
strconv.Itoa(earlierBytes+lineBytes(t, report)))
|
||||
strconv.Itoa(3*fileBytes+lineBytes(t, report)))
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
@@ -182,9 +204,55 @@ func TestCapCountsReportFilesAlreadyInDataDir(t *testing.T) {
|
||||
t.Fatalf("report that fills the cap exactly: %v", err)
|
||||
}
|
||||
|
||||
if !exists(t, oldest) {
|
||||
t.Fatal("oldest report file deleted while there was room")
|
||||
}
|
||||
|
||||
err = buf.Append(report)
|
||||
if !errors.Is(err, reportbuf.ErrFull) {
|
||||
t.Fatalf("report past the cap: error = %v, want ErrFull", err)
|
||||
if err != nil {
|
||||
t.Fatalf("report past the cap: %v", err)
|
||||
}
|
||||
|
||||
if exists(t, oldest) {
|
||||
t.Fatal("oldest report file kept when room was needed")
|
||||
}
|
||||
|
||||
for _, path := range kept {
|
||||
if !exists(t, path) {
|
||||
t.Fatalf("%s deleted; only the oldest report file should be", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestStartDeletesFilesPastCap starts on report files past the cap,
|
||||
// as after the cap is lowered: the oldest are deleted until the rest
|
||||
// fit.
|
||||
func TestStartDeletesFilesPastCap(t *testing.T) {
|
||||
const fileBytes = 100
|
||||
|
||||
dir := t.TempDir()
|
||||
oldest := reportFilePath(dir, 1)
|
||||
kept := []string{reportFilePath(dir, 2), reportFilePath(dir, 3)}
|
||||
|
||||
writeBytes(t, oldest, fileBytes)
|
||||
|
||||
for _, path := range kept {
|
||||
writeBytes(t, path, fileBytes)
|
||||
}
|
||||
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(len(kept)*fileBytes))
|
||||
|
||||
startBuffer(t)
|
||||
|
||||
if exists(t, oldest) {
|
||||
t.Fatal("oldest report file kept, though the files were past the cap")
|
||||
}
|
||||
|
||||
for _, path := range kept {
|
||||
if !exists(t, path) {
|
||||
t.Fatalf("%s deleted, though the rest fit without it", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,8 +263,9 @@ func TestWrittenReportsCountAtFileSize(t *testing.T) {
|
||||
// Repetitive, so its file is far smaller than its JSON.
|
||||
report := map[string]string{"id": strings.Repeat("a", 1000)}
|
||||
size := lineBytes(t, report)
|
||||
dir := t.TempDir()
|
||||
|
||||
t.Setenv("DATA_DIR", t.TempDir())
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
// Room for the report twice over only if the first one counts
|
||||
// at its file's size by the time the second arrives.
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(2*size-1))
|
||||
@@ -217,13 +286,22 @@ func TestWrittenReportsCountAtFileSize(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("second report, after the first was written: %v", err)
|
||||
}
|
||||
|
||||
if !hasReportFile(t, dir) {
|
||||
t.Fatal("first report's file deleted, though the second fit beside it")
|
||||
}
|
||||
}
|
||||
|
||||
// TestWrittenReportsKeepCounting writes one report file after another
|
||||
// under a small cap: each report must be taken while the files on disk
|
||||
// leave room for it, and refused once they do not.
|
||||
func TestWrittenReportsKeepCounting(t *testing.T) {
|
||||
const maxBytes = 200
|
||||
// TestWrittenFilesDeletedToMakeRoom writes one report file after
|
||||
// another under a small cap. Every report must be taken; files are
|
||||
// deleted only when the report would not fit beside them, and the
|
||||
// files kept leave room for it.
|
||||
func TestWrittenFilesDeletedToMakeRoom(t *testing.T) {
|
||||
const (
|
||||
maxBytes = 200
|
||||
// One file each, which take far more than maxBytes together.
|
||||
reports = 50
|
||||
)
|
||||
|
||||
report := map[string]string{"id": "written"}
|
||||
size := int64(lineBytes(t, report))
|
||||
@@ -234,23 +312,24 @@ func TestWrittenReportsKeepCounting(t *testing.T) {
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
// Every file takes at least a byte, so they fill the cap within
|
||||
// maxBytes rounds.
|
||||
for range maxBytes {
|
||||
used := reportFilesBytes(t, dir)
|
||||
for range reports {
|
||||
before := reportFilesBytes(t, dir)
|
||||
|
||||
err := buf.Append(report)
|
||||
if used+size > maxBytes {
|
||||
if !errors.Is(err, reportbuf.ErrFull) {
|
||||
t.Fatalf("with %d bytes of report files: error = %v, "+
|
||||
"want ErrFull", used, err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("with %d bytes of report files: %v", used, err)
|
||||
t.Fatalf("with %d bytes of report files: %v", before, err)
|
||||
}
|
||||
|
||||
after := reportFilesBytes(t, dir)
|
||||
|
||||
if before+size <= maxBytes && after != before {
|
||||
t.Fatalf("files deleted, though the report fit beside "+
|
||||
"their %d bytes", before)
|
||||
}
|
||||
|
||||
if after+size > maxBytes {
|
||||
t.Fatalf("%d bytes of report files kept, leaving no room "+
|
||||
"for the report", after)
|
||||
}
|
||||
|
||||
err = buf.Flush()
|
||||
@@ -258,8 +337,217 @@ func TestWrittenReportsKeepCounting(t *testing.T) {
|
||||
t.Fatalf("flush: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.Fatal("the report files never filled the cap")
|
||||
// TestFailedDeletionStillCounts makes deleting the oldest report file
|
||||
// fail. It is still there, so it still takes room, and the next oldest
|
||||
// is deleted in its place.
|
||||
func TestFailedDeletionStillCounts(t *testing.T) {
|
||||
const fileBytes = 100
|
||||
|
||||
report := map[string]string{"id": "stuck"}
|
||||
dir := t.TempDir()
|
||||
stuck := reportFilePath(dir, 1)
|
||||
next := reportFilePath(dir, 2)
|
||||
newest := reportFilePath(dir, 3)
|
||||
|
||||
for _, path := range []string{stuck, next, newest} {
|
||||
writeBytes(t, path, fileBytes)
|
||||
}
|
||||
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(3*fileBytes))
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
// A directory that is not empty cannot be deleted, even by root,
|
||||
// which the tests run as in the backend image.
|
||||
err := os.Remove(stuck)
|
||||
if err != nil {
|
||||
t.Fatalf("remove %s: %v", stuck, err)
|
||||
}
|
||||
|
||||
err = os.Mkdir(stuck, 0o750)
|
||||
if err != nil {
|
||||
t.Fatalf("make directory %s: %v", stuck, err)
|
||||
}
|
||||
|
||||
writeBytes(t, filepath.Join(stuck, "file"), 1)
|
||||
|
||||
err = buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("report past the cap: %v", err)
|
||||
}
|
||||
|
||||
if exists(t, next) {
|
||||
t.Fatal("next oldest report file kept: the failed deletion " +
|
||||
"counted as making room")
|
||||
}
|
||||
|
||||
if !exists(t, newest) {
|
||||
t.Fatal("newest report file deleted, though deleting one made room")
|
||||
}
|
||||
}
|
||||
|
||||
// TestFileDeletedByHandFreesRoom deletes the oldest report file by
|
||||
// hand after start. When room is needed, its room counts as freed, so
|
||||
// no other file is deleted.
|
||||
func TestFileDeletedByHandFreesRoom(t *testing.T) {
|
||||
const fileBytes = 100
|
||||
|
||||
report := map[string]string{"id": "by-hand"}
|
||||
dir := t.TempDir()
|
||||
gone := reportFilePath(dir, 1)
|
||||
kept := reportFilePath(dir, 2)
|
||||
|
||||
writeBytes(t, gone, fileBytes)
|
||||
writeBytes(t, kept, fileBytes)
|
||||
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(2*fileBytes))
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
err := os.Remove(gone)
|
||||
if err != nil {
|
||||
t.Fatalf("remove %s: %v", gone, err)
|
||||
}
|
||||
|
||||
err = buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("report past the cap: %v", err)
|
||||
}
|
||||
|
||||
if !exists(t, kept) {
|
||||
t.Fatal("report file deleted, though the one deleted by hand " +
|
||||
"had made room")
|
||||
}
|
||||
}
|
||||
|
||||
// TestFileBeingWrittenIsNeverDeleted holds the write of one report file
|
||||
// open while a second write completes, then sends a report that needs
|
||||
// room. Deleting either file would make it, and the one being written is
|
||||
// the older, but only the complete one may be deleted. Once the first
|
||||
// write is complete, its file is deleted when room is needed.
|
||||
func TestFileBeingWrittenIsNeverDeleted(t *testing.T) {
|
||||
report := map[string]string{"id": "writing"}
|
||||
|
||||
t.Setenv("DATA_DIR", t.TempDir())
|
||||
// Room for two reports waiting to be written, but not for two
|
||||
// beside a report file.
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(2*lineBytes(t, report)))
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
created := make(chan string)
|
||||
release := make(chan struct{})
|
||||
|
||||
buf.OnFileCreated(func(f *os.File) {
|
||||
created <- f.Name()
|
||||
|
||||
<-release
|
||||
})
|
||||
|
||||
err := buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("first report: %v", err)
|
||||
}
|
||||
|
||||
flushed := make(chan error)
|
||||
|
||||
go func() { flushed <- buf.Flush() }()
|
||||
|
||||
writing := <-created
|
||||
|
||||
// Only the first write is held; the second goes through, and
|
||||
// so do the writes after it, the final one at stop included.
|
||||
var complete string
|
||||
|
||||
buf.OnFileCreated(func(f *os.File) { complete = f.Name() })
|
||||
|
||||
// Errorf, not Fatalf, until the first write is released, so that a
|
||||
// failure here does not leave it held.
|
||||
err = buf.Append(report)
|
||||
if err != nil {
|
||||
t.Errorf("second report: %v", err)
|
||||
}
|
||||
|
||||
err = buf.Flush()
|
||||
if err != nil {
|
||||
t.Errorf("flush of the second report: %v", err)
|
||||
}
|
||||
|
||||
err = buf.Append(report)
|
||||
if err != nil {
|
||||
t.Errorf("report that needs room: %v", err)
|
||||
}
|
||||
|
||||
if !exists(t, writing) {
|
||||
t.Error("report file deleted while it was being written")
|
||||
}
|
||||
|
||||
if exists(t, complete) {
|
||||
t.Error("complete report file kept, though room was needed")
|
||||
}
|
||||
|
||||
close(release)
|
||||
|
||||
err = <-flushed
|
||||
if err != nil {
|
||||
t.Fatalf("flush of the first report: %v", err)
|
||||
}
|
||||
|
||||
err = buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("report after the first write was complete: %v", err)
|
||||
}
|
||||
|
||||
if exists(t, writing) {
|
||||
t.Fatal("complete report file kept when room was needed")
|
||||
}
|
||||
}
|
||||
|
||||
// TestFailedWriteStopsCounting makes a write fail once its file is
|
||||
// created. Its reports are lost, so they stop counting, and the part of
|
||||
// the file written is removed, so it takes no room.
|
||||
func TestFailedWriteStopsCounting(t *testing.T) {
|
||||
report := map[string]string{"id": "failed"}
|
||||
|
||||
t.Setenv("DATA_DIR", t.TempDir())
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(lineBytes(t, report)))
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
var failed string
|
||||
|
||||
// Closing the file under the write makes the write fail.
|
||||
buf.OnFileCreated(func(f *os.File) {
|
||||
failed = f.Name()
|
||||
|
||||
_ = f.Close()
|
||||
})
|
||||
|
||||
err := buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("report that fills the cap exactly: %v", err)
|
||||
}
|
||||
|
||||
err = buf.Flush()
|
||||
if err == nil {
|
||||
t.Fatal("flush succeeded, though its file was closed under it")
|
||||
}
|
||||
|
||||
if exists(t, failed) {
|
||||
t.Fatal("file of the failed write kept")
|
||||
}
|
||||
|
||||
// Writes from here on, the final one at stop included, succeed.
|
||||
buf.OnFileCreated(func(*os.File) {})
|
||||
|
||||
err = buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("report after the failed write: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestConcurrentAppendsStopAtCap appends from many goroutines at once
|
||||
@@ -334,7 +622,11 @@ func TestTwoFlushesInOneMillisecond(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
files := readReportFiles(t, dir)
|
||||
files, err := readReportFiles(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("read report files: %v", err)
|
||||
}
|
||||
|
||||
if len(files) != flushes {
|
||||
t.Fatalf("%d report files after %d flushes", len(files), flushes)
|
||||
}
|
||||
@@ -347,6 +639,88 @@ func TestTwoFlushesInOneMillisecond(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestReportFileHoldsTheLinesAppended flushes three reports and reads
|
||||
// their file back: it must decompress to exactly their JSON lines, in
|
||||
// the order they were appended.
|
||||
func TestReportFileHoldsTheLinesAppended(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
for _, id := range []int{1, 2, 3} {
|
||||
err := buf.Append(map[string]int{"id": id})
|
||||
if err != nil {
|
||||
t.Fatalf("append report %d: %v", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
err := buf.Flush()
|
||||
if err != nil {
|
||||
t.Fatalf("flush: %v", err)
|
||||
}
|
||||
|
||||
files, err := readReportFiles(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("read report files: %v", err)
|
||||
}
|
||||
|
||||
want := `{"id":1}` + "\n" + `{"id":2}` + "\n" + `{"id":3}` + "\n"
|
||||
if len(files) != 1 || files[0] != want {
|
||||
t.Fatalf("report files = %q, want one holding %q", files, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestFlushAtSizeThreshold appends reports until the buffer holds
|
||||
// FlushSizeThreshold bytes. The append that gets it there must write
|
||||
// them all to one report file, with no call to Flush and the periodic
|
||||
// flush a minute away, and no earlier append may write one.
|
||||
func TestFlushAtSizeThreshold(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
// Large reports, so the threshold takes a few hundred appends.
|
||||
pad := strings.Repeat("a", 64<<10)
|
||||
|
||||
var appended strings.Builder
|
||||
|
||||
for id := 0; appended.Len() < reportbuf.FlushSizeThreshold; id++ {
|
||||
report := map[string]any{"id": id, "pad": pad}
|
||||
|
||||
err := buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("append report %d: %v", id, err)
|
||||
}
|
||||
|
||||
line, err := json.Marshal(report)
|
||||
if err != nil {
|
||||
t.Fatalf("marshal report %d: %v", id, err)
|
||||
}
|
||||
|
||||
appended.Write(line)
|
||||
appended.WriteByte('\n')
|
||||
}
|
||||
|
||||
// Append writes the file in the background, so wait for it.
|
||||
deadline := time.Now().Add(10 * time.Second)
|
||||
|
||||
for {
|
||||
files, err := readReportFiles(dir)
|
||||
if err == nil && len(files) == 1 && files[0] == appended.String() {
|
||||
return
|
||||
}
|
||||
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("%d report files (error: %v), want one holding the "+
|
||||
"%d bytes appended", len(files), err, appended.Len())
|
||||
}
|
||||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
// reportFilesBytes returns the total size of the report files in dir.
|
||||
func reportFilesBytes(t *testing.T, dir string) int64 {
|
||||
t.Helper()
|
||||
@@ -371,20 +745,19 @@ func reportFilesBytes(t *testing.T, dir string) int64 {
|
||||
}
|
||||
|
||||
// readReportFiles returns the decompressed contents of each report
|
||||
// file in dir.
|
||||
func readReportFiles(t *testing.T, dir string) []string {
|
||||
t.Helper()
|
||||
|
||||
// file in dir. A file still being written does not decompress, so it
|
||||
// gives an error.
|
||||
func readReportFiles(dir string) ([]string, error) {
|
||||
files := os.DirFS(dir)
|
||||
|
||||
names, err := fs.Glob(files, "reports-*.jsonl.zst")
|
||||
if err != nil {
|
||||
t.Fatalf("list report files: %v", err)
|
||||
return nil, fmt.Errorf("list report files: %w", err)
|
||||
}
|
||||
|
||||
dec, err := zstd.NewReader(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("create zstd decoder: %v", err)
|
||||
return nil, fmt.Errorf("create zstd decoder: %w", err)
|
||||
}
|
||||
defer dec.Close()
|
||||
|
||||
@@ -393,18 +766,26 @@ func readReportFiles(t *testing.T, dir string) []string {
|
||||
for _, name := range names {
|
||||
compressed, readErr := fs.ReadFile(files, name)
|
||||
if readErr != nil {
|
||||
t.Fatalf("read %s: %v", name, readErr)
|
||||
return nil, fmt.Errorf("read %s: %w", name, readErr)
|
||||
}
|
||||
|
||||
data, decErr := dec.DecodeAll(compressed, nil)
|
||||
if decErr != nil {
|
||||
t.Fatalf("decompress %s: %v", name, decErr)
|
||||
return nil, fmt.Errorf("decompress %s: %w", name, decErr)
|
||||
}
|
||||
|
||||
contents = append(contents, string(data))
|
||||
}
|
||||
|
||||
return contents
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
// reportFilePath returns the path in dir of a report file named as
|
||||
// written on the given day of January 2026, so that a lower day sorts
|
||||
// as older.
|
||||
func reportFilePath(dir string, day int) string {
|
||||
return filepath.Join(dir,
|
||||
fmt.Sprintf("reports-2026-01-%02dT00-00-00.000Z-1.jsonl.zst", day))
|
||||
}
|
||||
|
||||
func writeBytes(t *testing.T, path string, n int) {
|
||||
@@ -416,6 +797,21 @@ func writeBytes(t *testing.T, path string, n int) {
|
||||
}
|
||||
}
|
||||
|
||||
func exists(t *testing.T, path string) bool {
|
||||
t.Helper()
|
||||
|
||||
_, err := os.Stat(path)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return false
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("stat %s: %v", path, err)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func hasReportFile(t *testing.T, dir string) bool {
|
||||
t.Helper()
|
||||
|
||||
@@ -439,3 +835,85 @@ func hasReportFile(t *testing.T, dir string) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// TestFilesDeletedOldestFirstWhenWritesOverlap holds the write of an
|
||||
// older report file open until a newer one's write completes, then
|
||||
// releases it. When room is needed, the older file is deleted first,
|
||||
// though its write was the last to complete.
|
||||
func TestFilesDeletedOldestFirstWhenWritesOverlap(t *testing.T) {
|
||||
const maxBytes = 1000
|
||||
|
||||
report := map[string]string{"id": "overlap"}
|
||||
|
||||
t.Setenv("DATA_DIR", t.TempDir())
|
||||
t.Setenv("DATA_DIR_MAX_BYTES", strconv.Itoa(maxBytes))
|
||||
|
||||
buf := startBuffer(t)
|
||||
|
||||
created := make(chan string)
|
||||
release := make(chan struct{})
|
||||
|
||||
buf.OnFileCreated(func(f *os.File) {
|
||||
created <- f.Name()
|
||||
|
||||
<-release
|
||||
})
|
||||
|
||||
err := buf.Append(report)
|
||||
if err != nil {
|
||||
t.Fatalf("older report: %v", err)
|
||||
}
|
||||
|
||||
flushed := make(chan error)
|
||||
|
||||
go func() { flushed <- buf.Flush() }()
|
||||
|
||||
older := <-created
|
||||
|
||||
// Only the older write is held; the newer one goes through, and
|
||||
// so do the writes after it, the final one at stop included.
|
||||
var newer string
|
||||
|
||||
buf.OnFileCreated(func(f *os.File) { newer = f.Name() })
|
||||
|
||||
// Errorf, not Fatalf, until the older write is released, so that a
|
||||
// failure here does not leave it held.
|
||||
err = buf.Append(report)
|
||||
if err != nil {
|
||||
t.Errorf("newer report: %v", err)
|
||||
}
|
||||
|
||||
err = buf.Flush()
|
||||
if err != nil {
|
||||
t.Errorf("flush of the newer report: %v", err)
|
||||
}
|
||||
|
||||
close(release)
|
||||
|
||||
err = <-flushed
|
||||
if err != nil {
|
||||
t.Fatalf("flush of the older report: %v", err)
|
||||
}
|
||||
|
||||
info, err := os.Stat(newer)
|
||||
if err != nil {
|
||||
t.Fatalf("stat %s: %v", newer, err)
|
||||
}
|
||||
|
||||
// A report that fits beside the newer file alone, so deleting the
|
||||
// older one makes exactly the room it needs.
|
||||
pad := maxBytes - int(info.Size()) - lineBytes(t, map[string]string{"id": ""})
|
||||
|
||||
err = buf.Append(map[string]string{"id": strings.Repeat("a", pad)})
|
||||
if err != nil {
|
||||
t.Fatalf("report that needs room: %v", err)
|
||||
}
|
||||
|
||||
if exists(t, older) {
|
||||
t.Fatal("older report file kept when room was needed")
|
||||
}
|
||||
|
||||
if !exists(t, newer) {
|
||||
t.Fatal("newer report file deleted before the older one")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -53,7 +54,7 @@ func (s *Server) listenAndServe() {
|
||||
s.log.Info("http begin listen",
|
||||
"listenaddr", s.httpServer.Addr,
|
||||
"version", s.params.Globals.Version,
|
||||
"buildarch", s.params.Globals.Buildarch,
|
||||
"arch", runtime.GOARCH,
|
||||
)
|
||||
|
||||
err := s.httpServer.ListenAndServe()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# script/build: compile the static netwatch-server binary into the
|
||||
# backend project root, with its version and architecture stamped in.
|
||||
# backend project root, with its version stamped in.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
@@ -14,7 +14,7 @@ main() {
|
||||
version="${VERSION:-$(git describe --always --dirty 2>/dev/null || echo dev)}"
|
||||
|
||||
CGO_ENABLED=0 go build -trimpath \
|
||||
-ldflags "-s -w -X main.Version=$version -X main.Buildarch=$(uname -m)" \
|
||||
-ldflags "-s -w -X main.Version=$version" \
|
||||
-o netwatch-server ./cmd/netwatch-server/
|
||||
}
|
||||
|
||||
|
||||
+20
-2
@@ -14,16 +14,34 @@ set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
# The sha256 of the org standard .golangci.yml. When that file changes in
|
||||
# sneak/prompts and is copied here again, this changes with it.
|
||||
GOLANGCI_CONFIG_SHA256="a79b63a254602a5318db5d0e9a06bc71b84bf0c1d896305229d8bfed1d1b1776"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
if [ ! -f .golangci.yml ]; then
|
||||
echo "backend/.golangci.yml is missing. Copy the org standard verbatim" >&2
|
||||
echo "from https://git.eeqj.de/sneak/prompts/raw/branch/main/.golangci.yml" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(sha256sum .golangci.yml | cut -d' ' -f1)"
|
||||
if [ -z "$actual" ]; then
|
||||
echo "sha256sum is missing or printed no hash, so" >&2
|
||||
echo "backend/.golangci.yml could not be checked." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$actual" != "$GOLANGCI_CONFIG_SHA256" ]; then
|
||||
echo ".golangci.yml has drifted from the org standard." >&2
|
||||
echo "backend/.golangci.yml does not match GOLANGCI_CONFIG_SHA256" >&2
|
||||
echo "in backend/script/lint." >&2
|
||||
echo " expected $GOLANGCI_CONFIG_SHA256" >&2
|
||||
echo " actual $actual" >&2
|
||||
echo "Restore it verbatim from sneak/prompts; do not edit it." >&2
|
||||
echo "Compare it with the org standard," >&2
|
||||
echo "https://git.eeqj.de/sneak/prompts/raw/branch/main/.golangci.yml" >&2
|
||||
echo "- If they differ, it was edited here: restore the org standard" >&2
|
||||
echo " verbatim. Do not edit it." >&2
|
||||
echo "- If they are the same, the org standard changed: set" >&2
|
||||
echo " GOLANGCI_CONFIG_SHA256 in backend/script/lint to the actual hash." >&2
|
||||
exit 1
|
||||
fi
|
||||
golangci-lint run ./...
|
||||
|
||||
+10
-2
@@ -1,12 +1,20 @@
|
||||
#!/bin/sh
|
||||
# script/test: run the backend test suite.
|
||||
# script/test: run the backend test suite with the race detector and
|
||||
# coverage. Go's own -timeout bounds the tests and not their compile,
|
||||
# so a cold build cache cannot fail it. The race detector needs cgo,
|
||||
# and so a C compiler. If the tests fail, they run again with -v for
|
||||
# the details, and the script fails even if that run passes.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
timeout 30 go test ./...
|
||||
go test -timeout 30s -race -cover ./... || {
|
||||
echo "--- Rerunning with -v for details ---"
|
||||
go test -timeout 30s -race -v ./...
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// eslint's recommended rules over every JavaScript file in the repo.
|
||||
// script/frontend-lint runs it, in the frontend-lint stage of Dockerfile.
|
||||
import js from "@eslint/js";
|
||||
import globals from "globals";
|
||||
import { defineConfig } from "eslint/config";
|
||||
|
||||
export default defineConfig([
|
||||
js.configs.recommended,
|
||||
{
|
||||
// The page, and facts.js, which the viewport test runs inside it.
|
||||
files: ["src/**/*.js", "test/viewport/facts.js"],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
// vite.config.js defines these when it builds the page.
|
||||
__COMMIT_HASH__: "readonly",
|
||||
__COMMIT_FULL__: "readonly",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// Run by node: the tests, the viewport harness and these configs.
|
||||
files: ["test/**/*.js", "*.js"],
|
||||
ignores: ["test/viewport/facts.js"],
|
||||
languageOptions: { globals: globals.node },
|
||||
},
|
||||
]);
|
||||
@@ -9,6 +9,9 @@
|
||||
type="image/svg+xml"
|
||||
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📡</text></svg>"
|
||||
/>
|
||||
<!-- Linked here, not imported by src/main.js, so the unit tests can
|
||||
import that module in Node, which cannot import CSS. -->
|
||||
<link rel="stylesheet" href="/src/styles.css" />
|
||||
</head>
|
||||
<body class="bg-gray-900 text-white min-h-screen">
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@tailwindcss/vite": "^4.1.18",
|
||||
"autoprefixer": "^10.4.23",
|
||||
"eslint": "^10.12.0",
|
||||
"globals": "^17.13.0",
|
||||
"postcss": "^8.5.6",
|
||||
"prettier": "^3.8.1",
|
||||
"puppeteer-core": "25.5.0",
|
||||
|
||||
+14
-7
@@ -24,9 +24,9 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
# Pinned versions, 2026-07-07
|
||||
NODE_VERSION="22.17.0"
|
||||
# The oldest node the frontend's dependencies accept: the "engines"
|
||||
# field of puppeteer-core 25.5.0, the most demanding of them, asks for
|
||||
# 22.12.0 or newer, 2026-09-29. An older installed node is not used.
|
||||
NODE_MIN_VERSION="22.12.0"
|
||||
# field of eslint 10.12.0, the most demanding of them, asks for 22.13.0
|
||||
# or newer, 2026-10-03. An older installed node is not used.
|
||||
NODE_MIN_VERSION="22.13.0"
|
||||
NVM_VERSION="0.40.3"
|
||||
# sha256 of https://github.com/nvm-sh/nvm/archive/refs/tags/v0.40.3.tar.gz
|
||||
NVM_SHA256="5f4d6aaa04a177dc93c985e31dbc411ab6b8c6e1e21d8015dbc1372625fcd1d0"
|
||||
@@ -64,7 +64,8 @@ detect_pkgmgr() {
|
||||
fi
|
||||
}
|
||||
|
||||
# pkg_install <nix-attr> <apt-pkg> <brew-formula> <apk-pkg>
|
||||
# pkg_install <nix-attr> <apt-pkgs> <brew-formula> <apk-pkgs>: the apt
|
||||
# and apk arguments may each list several packages, separated by spaces.
|
||||
pkg_install() {
|
||||
detect_pkgmgr
|
||||
case "$PKGMGR" in
|
||||
@@ -74,10 +75,10 @@ pkg_install() {
|
||||
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
APT_UPDATED=1
|
||||
fi
|
||||
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y "$2"
|
||||
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y $2
|
||||
;;
|
||||
brew) brew install "$3" ;;
|
||||
apk) apk add --no-cache "$4" ;;
|
||||
apk) apk add --no-cache $4 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -253,6 +254,12 @@ main() {
|
||||
|
||||
if missing make; then pkg_install gnumake make make make; fi
|
||||
if missing git; then pkg_install git git git git; fi
|
||||
# The race detector in make test needs cgo, which Go turns on only
|
||||
# when it finds its C compiler, gcc on Linux. apt and apk ship the C
|
||||
# library headers apart from gcc.
|
||||
if missing gcc; then
|
||||
pkg_install gcc "gcc libc6-dev" gcc "gcc musl-dev"
|
||||
fi
|
||||
|
||||
ensure_node
|
||||
ensure_yarn
|
||||
@@ -263,7 +270,7 @@ main() {
|
||||
|
||||
if missing docker; then
|
||||
echo "bootstrap: docker not found; make lint, and so make check" >&2
|
||||
echo " and the pre-commit hook, need it to run the Go linter" >&2
|
||||
echo " and the pre-commit hook, need it to run the linters" >&2
|
||||
fi
|
||||
if [ -n "$path_hint" ] && [ -d "$BIN_DIR" ]; then
|
||||
echo "bootstrap: add $BIN_DIR to the front of your PATH, e.g." >&2
|
||||
|
||||
+2
-3
@@ -16,9 +16,8 @@ main() {
|
||||
"$SCRIPT_DIR/check"
|
||||
# Own line: a failing command substitution inside an argument does
|
||||
# not trip `set -e`, so the inline form degrades silently to an
|
||||
# empty constant. VERSION is computed here because .dockerignore
|
||||
# excludes .git, so `git describe` in a build stage yields an empty
|
||||
# version without failing.
|
||||
# empty constant. The VERSION build argument takes precedence over
|
||||
# the version a build stage derives from the .git in the context.
|
||||
version="$(git describe --tags --always --dirty 2>/dev/null || true)"
|
||||
[ -n "$version" ] || version="unknown"
|
||||
docker build --no-cache \
|
||||
|
||||
+2
-3
@@ -12,9 +12,8 @@ main() {
|
||||
cd "$ROOT"
|
||||
# Own line: a failing command substitution inside an argument does
|
||||
# not trip `set -e`, so the inline form degrades silently to an
|
||||
# empty constant. VERSION is computed here because .dockerignore
|
||||
# excludes .git, so `git describe` in a build stage yields an empty
|
||||
# version without failing.
|
||||
# empty constant. The VERSION build argument takes precedence over
|
||||
# the version a build stage derives from the .git in the context.
|
||||
version="$(git describe --tags --always --dirty 2>/dev/null || true)"
|
||||
[ -n "$version" ] || version="unknown"
|
||||
docker build --no-cache \
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#!/bin/sh
|
||||
# script/frontend-check: run the frontend half of the checks only (test,
|
||||
# lint, fmt-check). This exists for the frontend stage of Dockerfile, a
|
||||
# node image with neither Go nor Docker; the Dockerfile's lint and
|
||||
# backend build stages gate the backend half. Everywhere else, use
|
||||
# script/check, which covers the whole repo. Must not modify any files.
|
||||
# script/frontend-check: run the frontend tests and format check only.
|
||||
# This exists for the frontend stage of Dockerfile, a node image with
|
||||
# neither Go nor Docker; the Dockerfile's frontend-lint stage runs the
|
||||
# frontend linter, and its lint and builder stages gate the backend.
|
||||
# Everywhere else, use script/check, which covers the whole repo. Must
|
||||
# not modify any files.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
@@ -11,7 +12,6 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
"$ROOT/script/frontend-test"
|
||||
"$ROOT/script/frontend-lint"
|
||||
"$ROOT/script/frontend-fmt-check"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#!/bin/sh
|
||||
# script/frontend-lint: run the frontend linter (prettier in check mode).
|
||||
# script/frontend-lint: run eslint over the frontend. This runs inside
|
||||
# the frontend-lint stage of Dockerfile, the digest-pinned node image
|
||||
# with the packages from yarn.lock. From a checkout, run `make lint`,
|
||||
# which builds that stage.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
yarn prettier --check .
|
||||
yarn eslint .
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#!/bin/sh
|
||||
# script/frontend-test: run the frontend test suite. The frontend has no
|
||||
# unit tests; the production build serves as the test (fails on broken
|
||||
# code).
|
||||
# script/frontend-test: run the frontend test suite: the unit tests in
|
||||
# test/unit/ with Node's built-in test runner, then the production
|
||||
# build, which fails on broken code.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
timeout 30 node --test test/unit/*.test.js
|
||||
timeout 30 yarn build
|
||||
}
|
||||
|
||||
|
||||
+10
-8
@@ -1,19 +1,21 @@
|
||||
#!/bin/sh
|
||||
# script/lint: lint the whole repo: prettier over the frontend, then the
|
||||
# Go linter over backend/.
|
||||
# script/lint: lint the whole repo: eslint over the frontend, then the Go
|
||||
# linter over backend/.
|
||||
#
|
||||
# The Go linter runs only in Docker: this builds the lint stage of
|
||||
# Dockerfile, the digest-pinned golangci-lint image, which runs the
|
||||
# backend's fmt-check and lint targets. --no-cache makes the linter
|
||||
# really run every time rather than reuse an earlier result, and the
|
||||
# stage is built for its checks alone, so no image is kept.
|
||||
# No linter runs on the host: this builds the frontend-lint and lint
|
||||
# stages of Dockerfile, the digest-pinned node and golangci-lint images.
|
||||
# The first runs eslint; the second runs the backend's fmt-check and
|
||||
# lint targets. --no-cache makes each linter really run every time
|
||||
# rather than reuse an earlier result, and each stage is built for its
|
||||
# checks alone, so no image is kept.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
"$ROOT/script/frontend-lint"
|
||||
timeout 300 docker build --no-cache --target frontend-lint \
|
||||
--output type=cacheonly .
|
||||
timeout 300 docker build --no-cache --target lint \
|
||||
--output type=cacheonly .
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,14 +1,17 @@
|
||||
#!/bin/sh
|
||||
# script/test: run the test suite for the whole repo: the frontend at
|
||||
# the repo root, then the Go backend in backend/. Both halves together
|
||||
# get 30 seconds; each also keeps its own limit for the Dockerfiles.
|
||||
# the repo root, then the Go backend in backend/. Each half has its own
|
||||
# 30-second limit, and there is none around both: from a cold Go build
|
||||
# cache, compiling the backend's tests with the race detector can take
|
||||
# 30 seconds on its own, and Go's -timeout leaves the compile out.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
timeout 30 sh -c 'script/frontend-test && backend/script/test'
|
||||
script/frontend-test
|
||||
backend/script/test
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
+51
-26
@@ -1,14 +1,14 @@
|
||||
import "./styles.css";
|
||||
|
||||
// --- Configuration -----------------------------------------------------------
|
||||
|
||||
// Timing, axis labels, and display constants. Latency above maxLatency is
|
||||
// clamped to "unreachable". The sparkline Y-axis is capped at
|
||||
// Timing, axis labels, and display constants. A target check times out
|
||||
// after requestTimeout, 80% of updateInterval, so a round's checks have
|
||||
// all finished before the next round is due; latency above maxLatency is
|
||||
// recorded as a timeout. The sparkline Y-axis is capped at
|
||||
// graphMaxLatency — values above it pin to the top of the chart but still
|
||||
// display their real value in the latency figure. The history buffer holds
|
||||
// maxHistoryPoints samples (historyDuration / updateInterval).
|
||||
// reportInterval is how often collected samples are POSTed to the backend.
|
||||
const CONFIG = {
|
||||
export const CONFIG = {
|
||||
updateInterval: 3000,
|
||||
maxHistoryPoints: 100,
|
||||
reportInterval: 60000,
|
||||
@@ -16,7 +16,7 @@ const CONFIG = {
|
||||
return (this.maxHistoryPoints * this.updateInterval) / 1000;
|
||||
},
|
||||
get requestTimeout() {
|
||||
return Math.min(this.updateInterval - 100, 3000);
|
||||
return this.updateInterval * 0.8;
|
||||
},
|
||||
get maxLatency() {
|
||||
return this.requestTimeout;
|
||||
@@ -503,12 +503,16 @@ class Reporter {
|
||||
|
||||
// --- Latency Measurement -----------------------------------------------------
|
||||
|
||||
async function measureLatency(url) {
|
||||
// Checks one target. The check times out after CONFIG.requestTimeout; the
|
||||
// caller can give it up sooner through the optional signal, which also ends
|
||||
// it as a timeout.
|
||||
export async function measureLatency(url, signal) {
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(
|
||||
() => controller.abort(),
|
||||
CONFIG.requestTimeout,
|
||||
);
|
||||
signal?.addEventListener("abort", () => controller.abort());
|
||||
|
||||
const targetUrl = new URL(url);
|
||||
targetUrl.searchParams.set("_cb", Date.now().toString());
|
||||
@@ -1101,7 +1105,7 @@ function sortAndRebuildWAN(state) {
|
||||
|
||||
// --- Main Loop ---------------------------------------------------------------
|
||||
|
||||
async function tick(state, onOffline) {
|
||||
async function tick(state, signal, onOffline) {
|
||||
const ts = Date.now();
|
||||
|
||||
if (state.paused) {
|
||||
@@ -1123,11 +1127,12 @@ async function tick(state, onOffline) {
|
||||
log.debug(`Tick #${state.tickCount + 1} started`);
|
||||
|
||||
const results = await Promise.all(
|
||||
state.allHosts.map((h) => measureLatency(h.url)),
|
||||
state.allHosts.map((h) => measureLatency(h.url, signal)),
|
||||
);
|
||||
|
||||
// User may have paused while awaiting results — discard them
|
||||
if (state.paused) return;
|
||||
// User may have paused, or the next round may have given up this
|
||||
// one's checks, while awaiting results — discard them
|
||||
if (state.paused || signal.aborted) return;
|
||||
|
||||
state.tickCount++;
|
||||
|
||||
@@ -1168,9 +1173,10 @@ async function tick(state, onOffline) {
|
||||
|
||||
// --- Recovery Probe ----------------------------------------------------------
|
||||
|
||||
// When offline, rapidly poll 4 random WAN hosts every 500ms. As soon as any
|
||||
// responds, stop probing and fire a normal tick to refresh all hosts.
|
||||
function startRecoveryProbe(state, triggerTick) {
|
||||
// When offline, check 4 random WAN hosts every 500ms, giving up the checks
|
||||
// started 500ms before, so at most 4 are ever waiting. As soon as one
|
||||
// answers, stop probing and start a new round at once.
|
||||
function startRecoveryProbe(state, startRounds) {
|
||||
if (state._recoveryProbeId) return; // already running
|
||||
const candidates = [...state.wan];
|
||||
for (let i = candidates.length - 1; i > 0; i--) {
|
||||
@@ -1181,15 +1187,18 @@ function startRecoveryProbe(state, triggerTick) {
|
||||
log.notice(
|
||||
`Recovery probe started (${canaries.map((h) => h.name).join(", ")})`,
|
||||
);
|
||||
state._recoveryProbeId = setInterval(async () => {
|
||||
state._recoveryProbeId = setInterval(() => {
|
||||
if (state.paused) return;
|
||||
const results = await Promise.all(
|
||||
canaries.map((h) => measureLatency(h.url)),
|
||||
);
|
||||
if (results.some((r) => r.error === null)) {
|
||||
state._recoveryProbeChecks?.abort();
|
||||
const checks = new AbortController();
|
||||
state._recoveryProbeChecks = checks;
|
||||
for (const host of canaries) {
|
||||
measureLatency(host.url, checks.signal).then((r) => {
|
||||
if (r.error !== null || checks.signal.aborted) return;
|
||||
log.notice("Recovery probe: connectivity detected");
|
||||
stopRecoveryProbe(state);
|
||||
triggerTick();
|
||||
startRounds();
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
@@ -1198,6 +1207,7 @@ function stopRecoveryProbe(state) {
|
||||
if (state._recoveryProbeId) {
|
||||
clearInterval(state._recoveryProbeId);
|
||||
state._recoveryProbeId = null;
|
||||
state._recoveryProbeChecks?.abort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1374,18 +1384,34 @@ async function init() {
|
||||
updateClocks();
|
||||
setInterval(updateClocks, 1000);
|
||||
|
||||
// Rounds never overlap: a round first gives up the last round's checks
|
||||
// if they are still waiting, and the last round then records nothing.
|
||||
// At a steady interval they never are, as they time out at 80% of it;
|
||||
// they can be when a round starts early, after an interval change or
|
||||
// when the recovery probe finds a target answering.
|
||||
let roundChecks = new AbortController();
|
||||
function doTick() {
|
||||
tick(state, () => startRecoveryProbe(state, doTick));
|
||||
roundChecks.abort();
|
||||
roundChecks = new AbortController();
|
||||
tick(state, roundChecks.signal, () =>
|
||||
startRecoveryProbe(state, startRounds),
|
||||
);
|
||||
}
|
||||
|
||||
// Starts a round now and then one every CONFIG.updateInterval.
|
||||
let tickIntervalId;
|
||||
function startRounds() {
|
||||
clearInterval(tickIntervalId);
|
||||
doTick();
|
||||
let tickIntervalId = setInterval(doTick, CONFIG.updateInterval);
|
||||
tickIntervalId = setInterval(doTick, CONFIG.updateInterval);
|
||||
}
|
||||
|
||||
startRounds();
|
||||
|
||||
document
|
||||
.getElementById("interval-select")
|
||||
.addEventListener("change", (e) => {
|
||||
const newInterval = parseInt(e.target.value, 10);
|
||||
clearInterval(tickIntervalId);
|
||||
CONFIG.updateInterval = newInterval;
|
||||
log.notice(
|
||||
`Interval changed to ${humanDuration(newInterval / 1000)}, history reset`,
|
||||
@@ -1434,8 +1460,7 @@ async function init() {
|
||||
|
||||
// Start immediately with new interval
|
||||
stopRecoveryProbe(state);
|
||||
doTick();
|
||||
tickIntervalId = setInterval(doTick, CONFIG.updateInterval);
|
||||
startRounds();
|
||||
});
|
||||
|
||||
window.addEventListener("resize", () => handleResize(state));
|
||||
@@ -1444,7 +1469,7 @@ async function init() {
|
||||
|
||||
// Bootstrap only when loaded as the page: a real DOM containing the #app
|
||||
// mount point this module renders into. Importing the module in a unit test
|
||||
// (which has no #app) runs nothing, so buildReport can be tested in isolation.
|
||||
// (which has no #app) runs nothing, so its exports can be tested in isolation.
|
||||
if (typeof document !== "undefined" && document.getElementById("app")) {
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
// Unit tests for src/main.js, run by script/frontend-test with Node's
|
||||
// built-in test runner. Importing the module does not start the page.
|
||||
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { CONFIG, measureLatency } from "../../src/main.js";
|
||||
|
||||
// measureLatency writes timeouts to the debug log, which looks for its
|
||||
// panel in the page. There is no page here.
|
||||
globalThis.document = { getElementById: () => null };
|
||||
|
||||
// Mocks the clock for test t, so that a check lasting seconds takes no real
|
||||
// time, and replaces fetch with a target that answers after answerAfter
|
||||
// milliseconds of that clock, or never when answerAfter is Infinity. Both
|
||||
// are restored when the test ends.
|
||||
function mockTarget(t, answerAfter) {
|
||||
t.mock.timers.enable({ apis: ["setTimeout", "Date"] });
|
||||
t.mock.method(performance, "now", () => Date.now());
|
||||
t.mock.method(
|
||||
globalThis,
|
||||
"fetch",
|
||||
(url, { signal }) =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (answerAfter !== Infinity) setTimeout(resolve, answerAfter);
|
||||
signal.addEventListener("abort", () => reject(signal.reason));
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// The result of check if it has ended, otherwise "still waiting".
|
||||
function settled(check) {
|
||||
return Promise.race([
|
||||
check,
|
||||
new Promise((resolve) => setImmediate(resolve, "still waiting")),
|
||||
]);
|
||||
}
|
||||
|
||||
for (const interval of [10000, 30000]) {
|
||||
const timeout = interval * 0.8;
|
||||
// Over 3 seconds, which the timeout used to be capped at.
|
||||
const slowAnswer = timeout - 1000;
|
||||
|
||||
test(`at a ${interval}ms interval, an answer after ${slowAnswer}ms is recorded with its real time`, async (t) => {
|
||||
CONFIG.updateInterval = interval;
|
||||
mockTarget(t, slowAnswer);
|
||||
const check = measureLatency("https://target.test");
|
||||
t.mock.timers.tick(slowAnswer);
|
||||
assert.deepEqual(await settled(check), {
|
||||
latency: slowAnswer,
|
||||
error: null,
|
||||
});
|
||||
});
|
||||
|
||||
test(`at a ${interval}ms interval, a target that never answers is recorded as a timeout after ${timeout}ms`, async (t) => {
|
||||
CONFIG.updateInterval = interval;
|
||||
mockTarget(t, Infinity);
|
||||
const check = measureLatency("https://target.test");
|
||||
t.mock.timers.tick(timeout - 1);
|
||||
assert.equal(await settled(check), "still waiting");
|
||||
t.mock.timers.tick(1);
|
||||
assert.deepEqual(await settled(check), {
|
||||
latency: null,
|
||||
error: "timeout",
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -16,6 +16,10 @@ import { collectLayoutFacts } from "./facts.js";
|
||||
import { evaluateChecks, INTERACTIVE_SELECTORS } from "./checks.js";
|
||||
import { deriveViewports } from "./viewports.js";
|
||||
|
||||
// page.waitForFunction and page.evaluate run the functions given them in
|
||||
// the page, where these are defined.
|
||||
/* global document, requestAnimationFrame */
|
||||
|
||||
function required(name) {
|
||||
const value = process.env[name];
|
||||
if (!value) {
|
||||
@@ -62,7 +66,6 @@ function stableHash(text) {
|
||||
|
||||
async function connectBrowser() {
|
||||
const deadline = Date.now() + BROWSER_TIMEOUT_MS;
|
||||
let lastError;
|
||||
for (;;) {
|
||||
try {
|
||||
const response = await fetch(`${CDP_URL}/json/version`);
|
||||
@@ -77,9 +80,10 @@ async function connectBrowser() {
|
||||
});
|
||||
return { browser, version: info.Browser };
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
if (Date.now() > deadline) {
|
||||
throw new Error(`browser never came up: ${lastError}`);
|
||||
throw new Error(`browser never came up: ${error}`, {
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
await sleep(250);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,24 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@cacheable/memory@^2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@cacheable/memory/-/memory-2.2.0.tgz#72aeb8b051f6d597d10ac8595b94ad8302bd2239"
|
||||
integrity sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==
|
||||
dependencies:
|
||||
"@cacheable/utils" "^2.5.0"
|
||||
"@keyv/bigmap" "^1.3.1"
|
||||
hookified "^1.15.1"
|
||||
keyv "^5.6.0"
|
||||
|
||||
"@cacheable/utils@^2.5.0":
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@cacheable/utils/-/utils-2.5.0.tgz#534c91113aa48fe43baedb169550b6ee070ef303"
|
||||
integrity sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==
|
||||
dependencies:
|
||||
hashery "^1.5.1"
|
||||
keyv "^5.6.0"
|
||||
|
||||
"@emnapi/core@^1.7.1":
|
||||
version "1.8.1"
|
||||
resolved "https://registry.yarnpkg.com/@emnapi/core/-/core-1.8.1.tgz#fd9efe721a616288345ffee17a1f26ac5dd01349"
|
||||
@@ -154,6 +172,90 @@
|
||||
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz#9e585ab6086bef994c6e8a5b3a0481219ada862b"
|
||||
integrity sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==
|
||||
|
||||
"@eslint-community/eslint-utils@^4.8.0":
|
||||
version "4.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz#8911bd72b2c3640a543609e0400b8c4d2e7e7cb6"
|
||||
integrity sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==
|
||||
dependencies:
|
||||
eslint-visitor-keys "^3.4.3"
|
||||
|
||||
"@eslint-community/regexpp@^4.12.2":
|
||||
version "4.12.2"
|
||||
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.2.tgz#bccdf615bcf7b6e8db830ec0b8d21c9a25de597b"
|
||||
integrity sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==
|
||||
|
||||
"@eslint/config-array@^0.23.5":
|
||||
version "0.23.5"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.23.5.tgz#56e86d243049195d8acc0c06a1b3dfdc3fa3de95"
|
||||
integrity sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==
|
||||
dependencies:
|
||||
"@eslint/object-schema" "^3.0.5"
|
||||
debug "^4.3.1"
|
||||
minimatch "^10.2.4"
|
||||
|
||||
"@eslint/config-helpers@^0.7.0":
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/config-helpers/-/config-helpers-0.7.0.tgz#09ee4aa07b73f059ec2d4c74bf4b2ff02b322377"
|
||||
integrity sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==
|
||||
dependencies:
|
||||
"@eslint/core" "^1.2.1"
|
||||
|
||||
"@eslint/core@^1.2.1":
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/core/-/core-1.2.1.tgz#c1da7cd1b82fa8787f98b5629fb811848a1b63ce"
|
||||
integrity sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==
|
||||
dependencies:
|
||||
"@types/json-schema" "^7.0.15"
|
||||
|
||||
"@eslint/js@^10.0.1":
|
||||
version "10.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-10.0.1.tgz#1e8a876f50117af8ab67e47d5ad94d38d6622583"
|
||||
integrity sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==
|
||||
|
||||
"@eslint/object-schema@^3.0.5":
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-3.0.5.tgz#88e9bf4d11d2b19c082e78ebe7ce88724a5eb091"
|
||||
integrity sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==
|
||||
|
||||
"@eslint/plugin-kit@^0.7.3":
|
||||
version "0.7.3"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz#cc7268cc36405b331ef92db1bc37971f21d66fe1"
|
||||
integrity sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==
|
||||
dependencies:
|
||||
"@eslint/core" "^1.2.1"
|
||||
levn "^0.4.1"
|
||||
|
||||
"@humanfs/core@^0.19.2":
|
||||
version "0.19.2"
|
||||
resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.2.tgz#a8272ca03b2acf492670222b2320b6c421bfde60"
|
||||
integrity sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==
|
||||
dependencies:
|
||||
"@humanfs/types" "^0.15.0"
|
||||
|
||||
"@humanfs/node@^0.16.6":
|
||||
version "0.16.8"
|
||||
resolved "https://registry.yarnpkg.com/@humanfs/node/-/node-0.16.8.tgz#8f800cccc13f4f8cd3116e2d9c0a94939da3e3ed"
|
||||
integrity sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==
|
||||
dependencies:
|
||||
"@humanfs/core" "^0.19.2"
|
||||
"@humanfs/types" "^0.15.0"
|
||||
"@humanwhocodes/retry" "^0.4.0"
|
||||
|
||||
"@humanfs/types@^0.15.0":
|
||||
version "0.15.0"
|
||||
resolved "https://registry.yarnpkg.com/@humanfs/types/-/types-0.15.0.tgz#f2a09f62012390b2bff3fc6fb248ddec8c09a090"
|
||||
integrity sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==
|
||||
|
||||
"@humanwhocodes/module-importer@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c"
|
||||
integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==
|
||||
|
||||
"@humanwhocodes/retry@^0.4.0", "@humanwhocodes/retry@^0.4.2":
|
||||
version "0.4.3"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.3.tgz#c2b9d2e374ee62c586d3adbea87199b1d7a7a6ba"
|
||||
integrity sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==
|
||||
|
||||
"@jridgewell/gen-mapping@^0.3.5":
|
||||
version "0.3.13"
|
||||
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz#6342a19f44347518c93e43b1ac69deb3c4656a1f"
|
||||
@@ -188,6 +290,19 @@
|
||||
"@jridgewell/resolve-uri" "^3.1.0"
|
||||
"@jridgewell/sourcemap-codec" "^1.4.14"
|
||||
|
||||
"@keyv/bigmap@^1.3.1":
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@keyv/bigmap/-/bigmap-1.3.1.tgz#fc82fa83947e7ff68c6798d08907db842771ef2c"
|
||||
integrity sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==
|
||||
dependencies:
|
||||
hashery "^1.4.0"
|
||||
hookified "^1.15.0"
|
||||
|
||||
"@keyv/serialize@^1.1.1":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@keyv/serialize/-/serialize-1.1.1.tgz#0c01dd3a3483882af7cf3878d4e71d505c81fc4a"
|
||||
integrity sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==
|
||||
|
||||
"@napi-rs/wasm-runtime@^1.1.0":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.1.tgz#c3705ab549d176b8dc5172723d6156c3dc426af2"
|
||||
@@ -444,11 +559,46 @@
|
||||
dependencies:
|
||||
tslib "^2.4.0"
|
||||
|
||||
"@types/esrecurse@^4.3.1":
|
||||
version "4.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/esrecurse/-/esrecurse-4.3.1.tgz#6f636af962fbe6191b830bd676ba5986926bccec"
|
||||
integrity sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==
|
||||
|
||||
"@types/estree@1.0.8":
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e"
|
||||
integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==
|
||||
|
||||
"@types/estree@^1.0.6", "@types/estree@^1.0.8":
|
||||
version "1.0.9"
|
||||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.9.tgz#cf3f0e876d7bee15a93ab925b82bf570a3904a24"
|
||||
integrity sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==
|
||||
|
||||
"@types/json-schema@^7.0.15":
|
||||
version "7.0.15"
|
||||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
|
||||
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
|
||||
|
||||
acorn-jsx@^5.3.2:
|
||||
version "5.3.2"
|
||||
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
|
||||
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
|
||||
|
||||
acorn@^8.16.0:
|
||||
version "8.18.0"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.18.0.tgz#4faf01b2d6d326bfeed97aea1f52220b5f4c1940"
|
||||
integrity sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==
|
||||
|
||||
ajv@^6.14.0:
|
||||
version "6.15.0"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.15.0.tgz#07e982c74626167aa7a2495c53817892d7139492"
|
||||
integrity sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==
|
||||
dependencies:
|
||||
fast-deep-equal "^3.1.1"
|
||||
fast-json-stable-stringify "^2.0.0"
|
||||
json-schema-traverse "^0.4.1"
|
||||
uri-js "^4.2.2"
|
||||
|
||||
ansi-regex@^6.2.2:
|
||||
version "6.2.2"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.2.2.tgz#60216eea464d864597ce2832000738a0589650c1"
|
||||
@@ -470,11 +620,23 @@ autoprefixer@^10.4.23:
|
||||
picocolors "^1.1.1"
|
||||
postcss-value-parser "^4.2.0"
|
||||
|
||||
balanced-match@^4.0.2:
|
||||
version "4.0.4"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-4.0.4.tgz#bfb10662feed8196a2c62e7c68e17720c274179a"
|
||||
integrity sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==
|
||||
|
||||
baseline-browser-mapping@^2.9.0:
|
||||
version "2.9.19"
|
||||
resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.9.19.tgz#3e508c43c46d961eb4d7d2e5b8d1dd0f9ee4f488"
|
||||
integrity sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg==
|
||||
|
||||
brace-expansion@^5.0.8:
|
||||
version "5.0.12"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-5.0.12.tgz#995fbb4750a77c4d16a7dc942ff2ca6ef8e675ec"
|
||||
integrity sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==
|
||||
dependencies:
|
||||
balanced-match "^4.0.2"
|
||||
|
||||
browserslist@^4.28.1:
|
||||
version "4.28.1"
|
||||
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.28.1.tgz#7f534594628c53c63101079e27e40de490456a95"
|
||||
@@ -486,6 +648,17 @@ browserslist@^4.28.1:
|
||||
node-releases "^2.0.27"
|
||||
update-browserslist-db "^1.2.0"
|
||||
|
||||
cacheable@^2.5.0:
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/cacheable/-/cacheable-2.5.0.tgz#d142d41043e5a865f6053cc70ef4e3ad068bd5ce"
|
||||
integrity sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==
|
||||
dependencies:
|
||||
"@cacheable/memory" "^2.2.0"
|
||||
"@cacheable/utils" "^2.5.0"
|
||||
hookified "^1.15.0"
|
||||
keyv "^5.6.0"
|
||||
qified "^0.10.1"
|
||||
|
||||
caniuse-lite@^1.0.30001759, caniuse-lite@^1.0.30001760:
|
||||
version "1.0.30001766"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001766.tgz#b6f6b55cb25a2d888d9393104d14751c6a7d6f7a"
|
||||
@@ -508,6 +681,27 @@ cliui@^9.0.1:
|
||||
strip-ansi "^7.1.0"
|
||||
wrap-ansi "^9.0.0"
|
||||
|
||||
cross-spawn@^7.0.6:
|
||||
version "7.0.6"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
|
||||
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
|
||||
dependencies:
|
||||
path-key "^3.1.0"
|
||||
shebang-command "^2.0.0"
|
||||
which "^2.0.1"
|
||||
|
||||
debug@^4.3.1, debug@^4.3.2:
|
||||
version "4.4.3"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a"
|
||||
integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==
|
||||
dependencies:
|
||||
ms "^2.1.3"
|
||||
|
||||
deep-is@^0.1.3:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831"
|
||||
integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==
|
||||
|
||||
detect-libc@^2.0.3:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.1.2.tgz#689c5dcdc1900ef5583a4cb9f6d7b473742074ad"
|
||||
@@ -573,11 +767,149 @@ escalade@^3.1.1, escalade@^3.2.0:
|
||||
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5"
|
||||
integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==
|
||||
|
||||
escape-string-regexp@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
|
||||
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
|
||||
|
||||
eslint-scope@^9.1.2:
|
||||
version "9.1.2"
|
||||
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-9.1.2.tgz#b9de6ace2fab1cff24d2e58d85b74c8fcea39802"
|
||||
integrity sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==
|
||||
dependencies:
|
||||
"@types/esrecurse" "^4.3.1"
|
||||
"@types/estree" "^1.0.8"
|
||||
esrecurse "^4.3.0"
|
||||
estraverse "^5.2.0"
|
||||
|
||||
eslint-visitor-keys@^3.4.3:
|
||||
version "3.4.3"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
|
||||
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==
|
||||
|
||||
eslint-visitor-keys@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz#9e3c9489697824d2d4ce3a8ad12628f91e9f59be"
|
||||
integrity sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==
|
||||
|
||||
eslint@^10.12.0:
|
||||
version "10.12.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-10.12.0.tgz#4f2f7e679bdce9d71438c2900f2c8d4d297332b0"
|
||||
integrity sha512-npHjrHb2o4ehH3mE+YuxABR+0gyb0aVWCIolgJDArwCiHEIsonBm3ZKjel5b0U5+a+MbEvIyRCGCzD3eKKK2NA==
|
||||
dependencies:
|
||||
"@eslint-community/eslint-utils" "^4.8.0"
|
||||
"@eslint-community/regexpp" "^4.12.2"
|
||||
"@eslint/config-array" "^0.23.5"
|
||||
"@eslint/config-helpers" "^0.7.0"
|
||||
"@eslint/core" "^1.2.1"
|
||||
"@eslint/plugin-kit" "^0.7.3"
|
||||
"@humanfs/node" "^0.16.6"
|
||||
"@humanwhocodes/module-importer" "^1.0.1"
|
||||
"@humanwhocodes/retry" "^0.4.2"
|
||||
"@types/estree" "^1.0.6"
|
||||
ajv "^6.14.0"
|
||||
cross-spawn "^7.0.6"
|
||||
debug "^4.3.2"
|
||||
escape-string-regexp "^4.0.0"
|
||||
eslint-scope "^9.1.2"
|
||||
eslint-visitor-keys "^5.0.1"
|
||||
espree "^11.2.0"
|
||||
esquery "^1.7.0"
|
||||
esutils "^2.0.2"
|
||||
fast-deep-equal "^3.1.3"
|
||||
file-entry-cache "11.1.5 || >11.1.6 <12"
|
||||
find-up "^5.0.0"
|
||||
glob-parent "^6.0.2"
|
||||
ignore "^5.2.0"
|
||||
imurmurhash "^0.1.4"
|
||||
is-glob "^4.0.0"
|
||||
json-stable-stringify-without-jsonify "^1.0.1"
|
||||
minimatch "^10.2.5"
|
||||
natural-compare "^1.4.0"
|
||||
optionator "^0.9.3"
|
||||
|
||||
espree@^11.2.0:
|
||||
version "11.2.0"
|
||||
resolved "https://registry.yarnpkg.com/espree/-/espree-11.2.0.tgz#01d5e47dc332aaba3059008362454a8cc34ccaa5"
|
||||
integrity sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==
|
||||
dependencies:
|
||||
acorn "^8.16.0"
|
||||
acorn-jsx "^5.3.2"
|
||||
eslint-visitor-keys "^5.0.1"
|
||||
|
||||
esquery@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.7.0.tgz#08d048f261f0ddedb5bae95f46809463d9c9496d"
|
||||
integrity sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==
|
||||
dependencies:
|
||||
estraverse "^5.1.0"
|
||||
|
||||
esrecurse@^4.3.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921"
|
||||
integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==
|
||||
dependencies:
|
||||
estraverse "^5.2.0"
|
||||
|
||||
estraverse@^5.1.0, estraverse@^5.2.0:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
|
||||
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==
|
||||
|
||||
esutils@^2.0.2:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
|
||||
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==
|
||||
|
||||
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
|
||||
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
|
||||
|
||||
fast-json-stable-stringify@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
|
||||
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
|
||||
|
||||
fast-levenshtein@^2.0.6:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||
integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==
|
||||
|
||||
fdir@^6.5.0:
|
||||
version "6.5.0"
|
||||
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.5.0.tgz#ed2ab967a331ade62f18d077dae192684d50d350"
|
||||
integrity sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==
|
||||
|
||||
"file-entry-cache@11.1.5 || >11.1.6 <12":
|
||||
version "11.1.5"
|
||||
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-11.1.5.tgz#c8210eb055de63e68685ccfb6a017e386d4577d0"
|
||||
integrity sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==
|
||||
dependencies:
|
||||
flat-cache "^6.1.23"
|
||||
|
||||
find-up@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc"
|
||||
integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==
|
||||
dependencies:
|
||||
locate-path "^6.0.0"
|
||||
path-exists "^4.0.0"
|
||||
|
||||
flat-cache@^6.1.23:
|
||||
version "6.1.23"
|
||||
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-6.1.23.tgz#735dc888c271868d7301b3bbb8edba5028afb61d"
|
||||
integrity sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==
|
||||
dependencies:
|
||||
cacheable "^2.5.0"
|
||||
flatted "^3.4.2"
|
||||
hookified "^1.15.0"
|
||||
|
||||
flatted@^3.4.2:
|
||||
version "3.4.4"
|
||||
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.4.4.tgz#aeeca2a506303f0cee61c59e6c9f2a88d2f29fc6"
|
||||
integrity sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==
|
||||
|
||||
fraction.js@^5.3.4:
|
||||
version "5.3.4"
|
||||
resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-5.3.4.tgz#8c0fcc6a9908262df4ed197427bdeef563e0699a"
|
||||
@@ -598,16 +930,97 @@ get-east-asian-width@^1.0.0, get-east-asian-width@^1.5.0:
|
||||
resolved "https://registry.yarnpkg.com/get-east-asian-width/-/get-east-asian-width-1.6.0.tgz#216900f91df11a8b2c198c3e1d93d6c035a776b9"
|
||||
integrity sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA==
|
||||
|
||||
glob-parent@^6.0.2:
|
||||
version "6.0.2"
|
||||
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3"
|
||||
integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==
|
||||
dependencies:
|
||||
is-glob "^4.0.3"
|
||||
|
||||
globals@^17.13.0:
|
||||
version "17.13.0"
|
||||
resolved "https://registry.yarnpkg.com/globals/-/globals-17.13.0.tgz#ab2134b5ededbf2fbe2831dd0acc36f4f1ddeac5"
|
||||
integrity sha512-RwMTC61u7hrG3ZJMkZQOK4JLJrKS8QtoTii63EmWvFXHqycY9FObBJQCbsLxSO8kjKhWE5kV1GC+Vb1g3RI0Zg==
|
||||
|
||||
graceful-fs@^4.2.4:
|
||||
version "4.2.11"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
|
||||
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
|
||||
|
||||
hashery@^1.4.0, hashery@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/hashery/-/hashery-1.5.1.tgz#4ba82ad54911ac617467870845d57a9fe508a400"
|
||||
integrity sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==
|
||||
dependencies:
|
||||
hookified "^1.15.0"
|
||||
|
||||
hookified@^1.15.0, hookified@^1.15.1:
|
||||
version "1.15.1"
|
||||
resolved "https://registry.yarnpkg.com/hookified/-/hookified-1.15.1.tgz#b1fafeaa5489cdc29cb85546a8f837ed4ffbbcb6"
|
||||
integrity sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==
|
||||
|
||||
hookified@^2.1.1:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/hookified/-/hookified-2.2.0.tgz#1d024ac1668973dd5bcc4a96ab9ccdb7639ef8d4"
|
||||
integrity sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==
|
||||
|
||||
ignore@^5.2.0:
|
||||
version "5.3.2"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5"
|
||||
integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==
|
||||
|
||||
imurmurhash@^0.1.4:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
|
||||
integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==
|
||||
|
||||
is-extglob@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
|
||||
integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==
|
||||
|
||||
is-glob@^4.0.0, is-glob@^4.0.3:
|
||||
version "4.0.3"
|
||||
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
|
||||
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
|
||||
dependencies:
|
||||
is-extglob "^2.1.1"
|
||||
|
||||
isexe@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
|
||||
|
||||
jiti@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/jiti/-/jiti-2.6.1.tgz#178ef2fc9a1a594248c20627cd820187a4d78d92"
|
||||
integrity sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==
|
||||
|
||||
json-schema-traverse@^0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
|
||||
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
|
||||
|
||||
json-stable-stringify-without-jsonify@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
|
||||
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==
|
||||
|
||||
keyv@^5.6.0:
|
||||
version "5.6.0"
|
||||
resolved "https://registry.yarnpkg.com/keyv/-/keyv-5.6.0.tgz#03044074c6b4d072d0a62c7b9fa649537baf0105"
|
||||
integrity sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==
|
||||
dependencies:
|
||||
"@keyv/serialize" "^1.1.1"
|
||||
|
||||
levn@^0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
|
||||
integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==
|
||||
dependencies:
|
||||
prelude-ls "^1.2.1"
|
||||
type-check "~0.4.0"
|
||||
|
||||
lightningcss-android-arm64@1.30.2:
|
||||
version "1.30.2"
|
||||
resolved "https://registry.yarnpkg.com/lightningcss-android-arm64/-/lightningcss-android-arm64-1.30.2.tgz#6966b7024d39c94994008b548b71ab360eb3a307"
|
||||
@@ -682,6 +1095,13 @@ lightningcss@1.30.2:
|
||||
lightningcss-win32-arm64-msvc "1.30.2"
|
||||
lightningcss-win32-x64-msvc "1.30.2"
|
||||
|
||||
locate-path@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
|
||||
integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==
|
||||
dependencies:
|
||||
p-locate "^5.0.0"
|
||||
|
||||
magic-string@^0.30.21:
|
||||
version "0.30.21"
|
||||
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.21.tgz#56763ec09a0fa8091df27879fd94d19078c00d91"
|
||||
@@ -689,6 +1109,13 @@ magic-string@^0.30.21:
|
||||
dependencies:
|
||||
"@jridgewell/sourcemap-codec" "^1.5.5"
|
||||
|
||||
minimatch@^10.2.4, minimatch@^10.2.5:
|
||||
version "10.2.6"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.6.tgz#fd956bbe0b77241e9f15ac5dccb1c638060968ef"
|
||||
integrity sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==
|
||||
dependencies:
|
||||
brace-expansion "^5.0.8"
|
||||
|
||||
mitt@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/mitt/-/mitt-3.0.1.tgz#ea36cf0cc30403601ae074c8f77b7092cdab36d1"
|
||||
@@ -699,16 +1126,62 @@ modern-tar@^0.7.6:
|
||||
resolved "https://registry.yarnpkg.com/modern-tar/-/modern-tar-0.7.7.tgz#ca71d79603630076b10733b0751ccab284bbc1ef"
|
||||
integrity sha512-t9VmxaqrmANnEOBhpSDI6HD192Ge48k8vmWqQQL7hSFEqHEYwZbbsu49+aKLWZeRvFs3j1pMhXOqqF4kPlvjkQ==
|
||||
|
||||
ms@^2.1.3:
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
|
||||
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
|
||||
|
||||
nanoid@^3.3.11:
|
||||
version "3.3.11"
|
||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.11.tgz#4f4f112cefbe303202f2199838128936266d185b"
|
||||
integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==
|
||||
|
||||
natural-compare@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
|
||||
|
||||
node-releases@^2.0.27:
|
||||
version "2.0.27"
|
||||
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.27.tgz#eedca519205cf20f650f61d56b070db111231e4e"
|
||||
integrity sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==
|
||||
|
||||
optionator@^0.9.3:
|
||||
version "0.9.4"
|
||||
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.4.tgz#7ea1c1a5d91d764fb282139c88fe11e182a3a734"
|
||||
integrity sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==
|
||||
dependencies:
|
||||
deep-is "^0.1.3"
|
||||
fast-levenshtein "^2.0.6"
|
||||
levn "^0.4.1"
|
||||
prelude-ls "^1.2.1"
|
||||
type-check "^0.4.0"
|
||||
word-wrap "^1.2.5"
|
||||
|
||||
p-limit@^3.0.2:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
|
||||
integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
|
||||
dependencies:
|
||||
yocto-queue "^0.1.0"
|
||||
|
||||
p-locate@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834"
|
||||
integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==
|
||||
dependencies:
|
||||
p-limit "^3.0.2"
|
||||
|
||||
path-exists@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
|
||||
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
|
||||
|
||||
path-key@^3.1.0:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
|
||||
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
|
||||
|
||||
picocolors@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b"
|
||||
@@ -733,11 +1206,21 @@ postcss@^8.5.6:
|
||||
picocolors "^1.1.1"
|
||||
source-map-js "^1.2.1"
|
||||
|
||||
prelude-ls@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
||||
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
||||
|
||||
prettier@^3.8.1:
|
||||
version "3.8.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.8.1.tgz#edf48977cf991558f4fcbd8a3ba6015ba2a3a173"
|
||||
integrity sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==
|
||||
|
||||
punycode@^2.1.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
|
||||
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==
|
||||
|
||||
puppeteer-core@25.5.0:
|
||||
version "25.5.0"
|
||||
resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-25.5.0.tgz#a41b14d582056b998e0bc3561ac47c7615d38a53"
|
||||
@@ -750,6 +1233,13 @@ puppeteer-core@25.5.0:
|
||||
webdriver-bidi-protocol "0.4.2"
|
||||
ws "^8.21.1"
|
||||
|
||||
qified@^0.10.1:
|
||||
version "0.10.1"
|
||||
resolved "https://registry.yarnpkg.com/qified/-/qified-0.10.1.tgz#0640bf21bbe6ca540db290ad8f5fde4d870b8bda"
|
||||
integrity sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==
|
||||
dependencies:
|
||||
hookified "^2.1.1"
|
||||
|
||||
rollup@^4.43.0:
|
||||
version "4.57.0"
|
||||
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.57.0.tgz#9fa13c1fb779d480038f45708b5e01b9449b6853"
|
||||
@@ -784,6 +1274,18 @@ rollup@^4.43.0:
|
||||
"@rollup/rollup-win32-x64-msvc" "4.57.0"
|
||||
fsevents "~2.3.2"
|
||||
|
||||
shebang-command@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
|
||||
integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
|
||||
dependencies:
|
||||
shebang-regex "^3.0.0"
|
||||
|
||||
shebang-regex@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
|
||||
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
|
||||
|
||||
source-map-js@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46"
|
||||
@@ -836,6 +1338,13 @@ tslib@^2.4.0:
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
|
||||
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
|
||||
|
||||
type-check@^0.4.0, type-check@~0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
|
||||
integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==
|
||||
dependencies:
|
||||
prelude-ls "^1.2.1"
|
||||
|
||||
typed-query-selector@^2.12.2:
|
||||
version "2.12.2"
|
||||
resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.12.2.tgz#65e2462ac6b0aecfae1bfac1a4f3027070dbabaa"
|
||||
@@ -849,6 +1358,13 @@ update-browserslist-db@^1.2.0:
|
||||
escalade "^3.2.0"
|
||||
picocolors "^1.1.1"
|
||||
|
||||
uri-js@^4.2.2:
|
||||
version "4.4.1"
|
||||
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
|
||||
integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==
|
||||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
vite@^7.3.1:
|
||||
version "7.3.1"
|
||||
resolved "https://registry.yarnpkg.com/vite/-/vite-7.3.1.tgz#7f6cfe8fb9074138605e822a75d9d30b814d6507"
|
||||
@@ -868,6 +1384,18 @@ webdriver-bidi-protocol@0.4.2:
|
||||
resolved "https://registry.yarnpkg.com/webdriver-bidi-protocol/-/webdriver-bidi-protocol-0.4.2.tgz#f51bb71c2606e90e3d5727607c728b25d617b58b"
|
||||
integrity sha512-VSV+fzfChirL3e7jay2yUC7B4HQCGtEWEg/MSSQbK+qWbqeGlRLlXTzPpYr3XGUvbpDHumWZBJxgesg4N7dbtA==
|
||||
|
||||
which@^2.0.1:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
|
||||
integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
|
||||
dependencies:
|
||||
isexe "^2.0.0"
|
||||
|
||||
word-wrap@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
|
||||
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
|
||||
|
||||
wrap-ansi@^9.0.0:
|
||||
version "9.0.2"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-9.0.2.tgz#956832dea9494306e6d209eb871643bb873d7c98"
|
||||
@@ -904,6 +1432,11 @@ yargs@^18.0.0:
|
||||
y18n "^5.0.5"
|
||||
yargs-parser "^22.0.0"
|
||||
|
||||
yocto-queue@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
|
||||
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
|
||||
|
||||
zod@^3.24.1:
|
||||
version "3.25.76"
|
||||
resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.76.tgz#26841c3f6fd22a6a2760e7ccb719179768471e34"
|
||||
|
||||
Reference in New Issue
Block a user