Creating function using Realm Administration API emits read size limit exceeded errors

Trying to create a function returns
https status code 413 with a message of
{"error":"read size limit exceeded","error_code":"ReadSizeLimitExceeded"}

example node.js code that uses node-fetch npm package for http:

async function deploy() {
    const accessToken = await getAccessToken();
    console.log("accessToken", accessToken);
    const body = {
        "can_evaluate": {},
        "name": "slidesTriggerHandler",
        "private": true,
        "source": fs.readFileSync(path.join(__dirname, "./functions/slides/dist/index.js"))
    const appId = await getAppId();
    console.log("appId", appId);
    const projectId = "someprojectId";
    const url = `${projectId}/apps/${appId}/functions`;
    const res = await fetch(url, {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "Accept": "application/json",
            "Authorization": `Bearer ${accessToken}`,
        body: JSON.stringify(body)

    if (res.ok) {
        console.log(await res.json());
    } else {
        console.log(await res.text());

Also feedback, it’s highly frustrating that there is no information description on error codes on any of the APIs.

Hi @Govind_Rai, welcome to the community!

This error seems to be indicating that the source attribute is too large. If it’s a large file then you could try refactoring it into multiple, smaller functions.

Hi @Andrew_Morgan,
That is the case. Thanks for that.

Some feedback for the Functions Team:
Allow larger function sizes: For example Google Cloud Functions allows;
100MB (compressed) for sources.
500MB (uncompressed) for sources plus modules.

Have dependencies be automatically picked up/installed from a package.json file

Allow unlimited logging per execution and don’t truncate logs (currently you only get 10 logs and logs are truncated at 256 chars). Also allow formatted logging, currently we have to scroll right and read a really long non-wrapping lines.

When testing functions in the UI, if you have a long running function whether or purpose or on error, you don’t really know if the function has passed or failed. Adding a spinner when a function is executing will help with UX (I had to learn this after realizing my function is timing out but it took me a while to understand that and I though the UI was broken).

Some feedback for the Realm Admin API docs team:

Please create a SDK for the Realm Admin API to help consumers avoid writing repetitive code
Please document errors codes and messages.

Thanks for your help.

1 Like

Hi @Govind_Rai, thanks for circling back with this feedback.