Skip to content

feat(chart-renderer): render charts for MediaWiki's Chart extension - #230

Closed
lens0021 wants to merge 1 commit into
mainfrom
claude/project-thread-1otvom
Closed

lens0021 wants to merge 1 commit into
mainfrom
claude/project-thread-1otvom

Conversation

@lens0021

Copy link
Copy Markdown
Member

Requested by lens0021 · project thread

Part of femiwiki/femiwiki#671. Adds chart-renderer/, a Node.js function that Extension:Chart calls through $wgChartServiceUrl. With it, the wiki host needs neither Node.js nor a higher $wgMaxShellMemory. Node 22 does not start under the default 300 MB ulimit -v, and it does not start under 600 MB either.

How

  • It bundles Wikimedia's chart-renderer at commit 543b8ee with esbuild. Only renderChart() and validateRequestParams() are used, not the express/service-runner server, so the zip holds one 4.8 MB index.js (139 MB of node_modules otherwise).

  • No stored secret. Chart can't add headers, so the URL path is a JWT that STS signs for the instance role Femiwiki with GetWebIdentityToken. This is the same mechanism google-subject-token.php already uses. The function checks the following before reading the body:

    • the ES384 signature, against the account issuer's JWKS
    • iss, aud = chart-renderer, sub = the role ARN, and exp

    Tokens live an hour and are refreshed every 15 minutes, so a URL leaked into a log stops working soon.

  • deploy.yml gains runtime/handler per target. The uv steps skip Node targets, and a Node target runs npm ci --ignore-scripts && npm test before zipping. test.yml gets a chart-renderer job, and dependabot watches its npm lockfile.

Measured locally

The five upstream examples render in 11–98 ms each, with about 80 MB RSS after loading and 113 MB peak, so 256 MB of memory should be enough. Cold load of the bundle takes 160 ms.

Order

The function itself (Node 22 on arm64, function URL, reserved concurrency) comes from a femiwiki/infra PR, which must be applied before this merges. Otherwise the deploy fails on a function that doesn't exist yet. The wiki side (token cron and $wgChartServiceUrl) follows in docker-mediawiki.


Generated by Claude Code

A Node.js function that Chart reaches through $wgChartServiceUrl, so the
wiki's host needs neither Node.js nor a looser shell memory limit. It
bundles Wikimedia's chart-renderer at a pinned commit with esbuild,
without its HTTP server.

Chart cannot add headers, so the URL path carries a JWT that STS signs
for the wiki's instance role with GetWebIdentityToken. The function
checks its signature against the account's JWKS, its issuer, audience,
subject and expiry before reading the body. No secret is stored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WBX81tBhoTUA6zfe9snCjQ
@lens0021 lens0021 self-assigned this Oct 27, 2026
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.05%. Comparing base (6d121d7) to head (44a7174).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #230   +/-   ##
=======================================
  Coverage   96.05%   96.05%           
=======================================
  Files          10       10           
  Lines        1116     1116           
=======================================
  Hits         1072     1072           
  Misses         44       44           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member Author

Closing: the renderer now lives in femiwiki/terraform-aws-mediawiki-chart-renderer, which ships the bundled code itself, and femiwiki/infra#1567 deploys it from there.


Generated by Claude Code

@lens0021 lens0021 closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants