phibac developer docs

Limits

This page lists every limit your app (the web app you build) or your developer tools can run into on this server, https://phibac.com: what each one means in practice and what happens when you go over it. The values are this server's settings. Another server can be set differently: its operator sets each limit with an environment variable named PB_LIMIT_ followed by the limit's name. The local server that npx phibac dev runs uses the built-in values unless you set such a variable.

When a limit gives an error, the error's code is named and linked to Errors and how to fix them.

At a glance

Limit On this server Over it
Record data 256 KB per record payload_too_large
File 100 MB per file payload_too_large
Changes in one batch 100 invalid_request
Size of one batch 4 MB payload_too_large
Records in one query request 500 (50 if none is asked for) No error: the SDK asks for the next page
Records from an SDK query without limit(n) 500 No error: the rest are left out
Values in an "in" filter 500 invalid_request
Changes in one catch-up request 1,000 No error: the SDK asks for the next page
Collection name 128 characters invalid_request
Field name 64 characters invalid_request
App name 1 to 100 bytes invalid_request
Origins per app 20 invalid_request
Record history 30 days Older versions are removed
Short-lived access 15 minutes The SDK renews it by itself
Stored sign-in left unused 30 days unauthorized

The sections below explain each limit.

Data

Record size

A record's data (its fields, as JSON) can be at most 256 KB. The same limit holds in sandbox collections. A larger record is refused with payload_too_large. Because writes are queued, create() and update() still return at once; the refusal arrives later through backend.onConflict(), and the SDK drops that change and sends the others. Store large content, such as a photo, as a file and keep the file's ID in a fileRef field, or split the record.

File size

A file can be at most 100 MB. files.upload() checks this with the server before it sends any bytes, and a larger file is refused with payload_too_large. Make the file smaller before you upload it, for example by resizing an image. See Upload and show files.

Batches

The SDK sends the changes waiting in its write queue (the changes the server does not have yet) to the server in batches. One batch can hold at most 100 changes and 4 MB of data. The SDK splits its queue into batches by itself, so your app does not handle this. If the server refuses a whole batch as too large, the SDK sends the changes one at a time, so only a change that is too large on its own is dropped and reported through onConflict.

Over the limits, the server refuses a batch with too many changes with invalid_request and a batch with too much data with payload_too_large.

Other request sizes

Every other request has a size limit of its own. The ones you can meet:

  • Publishing a schema. A collection definition may hold a little more than one record: 256 KB plus a fixed allowance. A larger one is refused with payload_too_large when you run npx phibac deploy.
  • Creating or changing an app through the developer API: the same size as a schema.
  • The agent tools. One request to the agent tools endpoint has a fixed size limit; a larger one is refused with payload_too_large. Collection definitions are far smaller.

Queries

Records per request

One query request to the server returns at most 500 records, and 50 when the request does not say how many. A query's get() asks the server for as many pages as it needs, so your app never sees this limit. It is no error.

Records from one SDK query

A query without limit(n) returns at most 500 records, online and offline alike. This is the SDK's own setting, not the server's. With limit(n) it returns up to n records, fetching as many pages from the server as needed. list() and a collection's subscribe() have no such limit: they return every record in the browser's copy of the data. See Query, sort and live updates.

Values in an "in" filter

An "in" filter, such as where("color", "in", ["blue", "green"]), can list at most 500 values. More are refused with invalid_request. Split the list over several queries and merge the results by rkey in your code.

Catch-up after being offline

When the SDK catches up with changes made elsewhere, for example on another device, one request returns at most 1,000 changes. The SDK asks for the next page by itself. It is no error.

Searching schemas and generating types

These limits apply to the developer tools:

  • A schema search returns 50 collections, or up to 500 when it asks for more. A request for more than that gets that many.
  • One request for TypeScript types (npx phibac generate, the generate_types tool) can name at most 500 different collections. More are refused with invalid_request.

Names

  • Collection names are at most 128 characters. See pb.config.ts reference for the other rules.
  • Field names are at most 64 characters.
  • App names are 1 to 100 bytes long once spaces at the start and end are removed. The length is counted in bytes of UTF-8 text: one byte for each plain letter, digit or space, and more for accented letters and emoji. An app name must also fit on one line, without control or invisible characters.
  • Origins: an app can register at most 20 origins (an origin is the scheme, host and port a page is served from, such as https://notes.example.com).

A name or list that breaks one of these is refused with invalid_request, from npx phibac init, npx phibac deploy, the developer API or the agent tools.

History

Record history

When a record is updated or deleted, the version it replaced is kept for 30 days. Until then the user can restore it from their account area; after that it is removed. See Collections and records.

Changes sent twice

Every change the SDK queues has an ID of its own. The server remembers the ID of each change it has applied for 30 days, so a change the SDK sends again in that time, for example after a dropped connection, is applied only once.

These lifetimes are handled by the SDK. You meet them only when something goes wrong. How sign-in works explains the sign-in ones.

  • Short-lived access: 15 minutes. The SDK renews it by itself before it runs out.
  • Stored sign-in: 30 days, counted from the last renewal. The SDK renews the sign-in each time your app uses the server after the short-lived access has run out, so a sign-in your app keeps using does not expire. A sign-in left unused for that long expires; requests then fail with unauthorized and the user signs in again from a click.
  • Repeated renewal: a renewal that is sent again within 1 minute of the first, for example because the answer to the first was lost, still works. Later, the repeat ends the sign-in.
  • Sign-in code: 1 minute. After the user approves your app, the popup hands the SDK a one-time code, which the SDK exchanges at once.
  • Device clock: each request carries the time it was made, and the server accepts a time up to 1 minute away from its own clock. When a device's clock is further off, the server sends its own time and the SDK corrects for it and tries again, once.
  • Consent request: 15 minutes. A consent popup that is not answered in that time expires; call requestAccess() again from a click.
  • Upload link: 10 minutes. files.upload() gets a link to send the file's bytes to and uses it at once.
  • Download link: 5 minutes. An address from files.url() stops working after that; call files.url() again each time you show the file in a new place.
  • Live-update ticket: 30 seconds, used once. The SDK asks for one each time it opens the live connection.
  • Request time-out: the SDK gives up on a request that gets no complete answer within a fixed time and fails it with network. The write queue tries again later by itself.

Live updates

  • Permission checks: an open live connection is checked again every 15 seconds. When the user disconnects your app, its live updates stop at the next check. When the user revokes your app's permission to read another app's collection, live updates for that collection stop at once.
  • Unused tickets: one account can hold only a few live-update tickets it has not used yet. The SDK opens a connection with every ticket it asks for, so this passes by itself; when it happens, the SDK gets rate_limited and tries again later.

Reading another app's data

Every read of another app's data is shown in the user's activity log. When one app reads more than 1,000 records of another app's data in one day, the user is also emailed. See Read another app's data.

Password sign-in

Users can sign in to the server with a password. These limits apply on the server's own sign-in pages, never to your app's requests:

  • Password length: at least 10 characters.
  • Wrong guesses: after 10 wrong passwords for one email address within an hour, or 30 from one network, password sign-in is refused with "try again later" until the hour has passed. A browser the account remembers is not held back by other people's guesses at its address.
  • Emailed code: a password sign-in in a browser that is new to the account needs a code sent by email. It works for 10 minutes; after 5 wrong codes the user starts again. At most 5 codes are emailed to one account in an hour.
  • Remembered browser: a browser where the user ticked "Remember this browser" is not asked for a code for 90 days.
  • Sign-in that is not remembered: it ends when the browser closes, or after 12 hours at the latest.
  • Reset link: a link to choose a new password works for 1 hour, once. At most 3 are emailed to one address in an hour.

How sign-in works explains each.

Account pages

The server's account pages accept at most 5 sign-ups per hour from one network; more are refused with rate_limited and asked to try again later. You can meet this when you create many test accounts on one server.

Allowances

This server sets no allowances: there is no limit on how much an account stores, how many requests it sends or how much it downloads, beyond the limits above. It never sends storage_full or trial_ended.