Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Opt-out for the module-load eval probe (strict CSP reports a violation on import)

Aperta Adatta ai principianti
#3,276 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, typescript

Direzione di ricerca

Inizia da packages/typegpu/src/data/compiledIO.ts, dove vive il probe EVAL_ALLOWED_IN_ENV al caricamento del modulo. Leggi i tre design di opt-out suggeriti nell'issue e controlla come typegpu gestisce già le opzioni root/init per scegliere quella adatta. È fatto quando: importare typegpu sotto script-src 'self' non produce alcun report securitypolicyviolation, e il plain writer continua a essere usato con il suo avviso esistente quando eval non è disponibile.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

packages/typegpu/src/data/compiledIO.ts probes for eval support when the module loads:

export const EVAL_ALLOWED_IN_ENV: boolean = (() => {
  try {
    new Function('return true');
    return true;
  } catch {
    return false;
  }
})();

Under a strict Content Security Policy without 'unsafe-eval', the try/catch keeps this from breaking anything: typegpu falls back to the plain writer, and since #2758/#2771 it warns once. But the browser still files a securitypolicyviolation (script-src, eval) the moment typegpu is imported, before any buffer is written.

Hosts that embed apps in sandboxed iframes with a strict CSP (MCP Apps / ChatGPT apps, browser extensions, enterprise pages with CSP reporting) treat any such report as a policy failure. An app that never wants compiled writers can't avoid the report today short of patching the package.

Request

An opt-out that skips the probe, so the plain writer is used without ever calling new Function. Any of these would work for us:

  • a global flag read before the probe, like zod's globalThis.__zod_globalConfig = { jitless: true };
  • a lazy probe that runs only the first time a compiled writer is actually requested, plus a root or init option to disable compiled writers;
  • a build-time define (TYPEGPU_NO_EVAL) that tree-shakes the probe.
Repro
  1. Serve a page with Content-Security-Policy: script-src 'self'.
  2. Add document.addEventListener('securitypolicyviolation', e => console.log(e.violatedDirective, e.blockedURI)).
  3. Import typegpu. One script-src / eval violation is logged at import, with no GPU work done.

Seen on typegpu 0.12.8. We currently carry a patch-package-style patch that hard-codes the plain writer and would drop it as soon as an opt-out exists. Thanks for TypeGPU!

Lingua principale
TypeScript
Stelle
3.3k
Fork
141
Merge medio
3g 8h
PR unite (30g)
72

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di software-mansion/TypeGPU

Tutte le issue di software-mansion/TypeGPU

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.