Skip to content

Document and address 32MB request body size limit #148

@jodeleeuw

Description

@jodeleeuw

Problem

Firebase Cloud Functions v2 (Cloud Run) enforces a hard 32MB limit on HTTP request body size (HTTP/1.x). This limit cannot be increased — it's a platform constraint, not a configuration option.

Most jsPsych experiment data is well under this limit (typical datasets are 50KB–5MB), but edge cases exist:

  • Base64 endpoint: webcam recordings, screen captures, or high-resolution images can easily exceed 32MB
  • Data endpoint: experiments with very high-frequency sampling (e.g., mouse tracking at 60Hz, eye tracking) over long sessions could approach the limit
  • No user-facing error: requests exceeding 32MB are rejected at the infrastructure layer before any function code runs, so no DataPipe error message or logging occurs — the researcher just sees a network error

Current behavior

When a payload exceeds 32MB:

  1. Cloud Run gateway rejects the request
  2. No function code executes (no logging, no persist, no queue)
  3. The client receives a connection error with no explanation
  4. Data is silently lost

Potential solutions (roughly ordered by effort)

1. Document the limit

Add a note to the FAQ and getting-started pages about the 32MB limit. Low effort but poor UX.

2. Client-side size check in jsPsych plugin

Add a pre-flight size check in @jspsych-contrib/plugin-pipe that warns or errors with a clear message if the payload exceeds ~30MB. Doesn't solve the problem but prevents silent data loss.

3. Client-side chunking

Split large payloads into <32MB chunks in the plugin, reassemble server-side. Moderate effort, backward-compatible for existing experiments.

4. Signed URL upload

Client requests a signed URL from a lightweight Cloud Function, uploads directly to Cloud Storage (no size limit), then a storage trigger or scheduled function processes it. Most robust solution but largest architectural change.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions