Skip to content

developer.mozilla.org's "Try it" widget always 404s on replay (missing permalink attribute) #394

Closed

Description

@benoit74

Context

Follow-up to #387/#389/#391/#393 (openzim/warc2zim#327). After fixing the earlier 4 issues, 3 of MDN's 4 "Try it" live-sample widgets render correctly, but the top, editable "Try it" widget (<interactive-example>) still always fails to load.

Root cause

<mdn-play-runner> (the component that actually renders the sandboxed iframe) picks its id source based on a single boolean property:

let p = i ? l : this._uuid;  // i = this.permalink, l = content-hash, this._uuid = crypto.randomUUID()

<mdn-live-sample-result> (the 3 working demos further down the page) always passes a literal permalink attribute to its inner <mdn-play-runner>, so it uses the deterministic, content-derived hash. <interactive-example> (the top widget) never does, across all three of its template variants (choices/console/tabbed) — presumably deliberate on MDN's side, since the widget is live-editable and recomputing a hash on every keystroke would be wasteful. But the initial, pre-edit code is just as content-stable as the other 3 demos; only the id source differs.

Confirmed directly: forcing .permalink = true on the top widget's mdn-play-runner via live DOM manipulation produces the exact same deterministic hash across repeated, completely independent page loads — same mechanism, same reproducibility as the other 3 widgets. But that only affects the live page during a crawl; a real viewer's browser runs the unmodified JS, where permalink still defaults to false, so it always calls crypto.randomUUID() fresh and never matches anything in a WARC.

Suggested fix

Patch interactive-example's JS chunk to always pass permalink to its <mdn-play-runner> templates, the same attribute <mdn-live-sample-result>'s template already always sets. This needs to be a host-scoped patch (developer.mozilla.org only) applied to the JS content during rewriting, not a general-purpose rewriting rule.

I'll attempt a local patch (in zimscraperlib.rewriting.js, alongside a small, explicitly host-gated table for this kind of narrow site-specific content fix) and open a PR against this issue.

Activity

  1. self-assigned this
    on Nov 6, 2026
  2. added theissue type on Nov 6, 2026
  3. added this to the 5.6.0 milestone on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions