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

Schema.isBase64 / isBase64Url throw RangeError on multi-megabyte strings

Chiusa
#9,592 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@magoz ci sta già lavorando.

Dal 20/10/2026.

  • #9593 di @magoz — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
backend, testing

Direzione di ricerca

Start with the Base64 and Base64Url checks in the Schema string checks and their existing tests. The issue shows the repeated-group regex throws on large valid inputs while flat character checks and the encoding decoders do not; compare those approaches and run the relevant Schema tests. Done means both checks handle multi-megabyte valid input without throwing and reject invalid input as a schema issue.

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

Descrizione

What version of Effect is running?

4.0.5 (also current main, bbedfc71c0)

What steps can reproduce the bug?
import { Schema } from "effect"

const input = "A".repeat(4_000_000) // valid Base64 / Base64Url, ~3 MB decoded

Schema.decodeUnknownSync(Schema.String.check(Schema.isBase64()))(input)
Schema.decodeUnknownSync(Schema.String.check(Schema.isBase64Url()))(input)
What is the expected behavior?

Both decode successfully (or fail with a schema issue for invalid input).

What do you see instead?
  • 4.0.5: RangeError: Maximum call stack size exceeded
  • main: Error: Sync adapter can only throw schema errors, cause Cause([Die(RangeError: Maximum call stack size exceeded)]). Schema.is and decodeUnknownResult throw too.
Additional information

The bare regex throws as well, so the problem is the pattern, not Schema:

/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/.test("A".repeat(4_000_000))
// RangeError: Maximum call stack size exceeded

V8's regexp engine keeps backtracking state for each iteration of the repeated (...{4})* group. On Node v24.21.0 (V8 13.6), both patterns accept 3,728,260 chars and throw from 3,728,264 chars (932,066 groups, ~2.67 MiB decoded). Base64 strings produced by Buffer#toString("base64") fail at the same length. The limit stays the same with --stack-size=400 and --stack-size=4000. Non-capturing (?:...) groups also throw at 8M chars. A flat ^[0-9a-zA-Z+/]*$ does not, and neither do Base64.decode / Base64Url.decode from effect/encoding (~20 ms at 8M chars).

In practice, Base64 payloads such as file attachments above ~2.7 MB cannot be validated. I checked the other regex-backed string checks (isTrimmed, isUUID, isGUID, isULID, isStringFinite, isStringBigInt, isStringSymbol, isUppercased, isCapitalized, isStartingWith) on 8M-char inputs, and none of them throw.

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
10h 7m
PR unite (30g)
808

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.