Error importing external dependencies

I am trying to use SheetJS js-xlsx as an external dependency. I have uploaded it as described in

I have the following Realm function:
exports = function(){ const XLSX = require("xlsx"); };
However, I get an error “execution time limit exceeded” when I run it. I’d appreciate any help solving this.

Hi @Ilya_Sytchev

Welcome to MongoDB community.

Have you tried saving this function and calling it from outside of the debug console.

Even from another function or a schedule trigger, do you get the same issue?


Thanks. I’ve just tried running this function both from another function and from a scheduled trigger but I got the same error message.

Please verify that this package does not use an unsuprted module:

If not please provide the application url and Ill try to lookup.
If its urgent please open a support call.


Thanks, I see. It would be great if you could have a look at the package:


We are looking into that. I involved the realm team.

We suspect that the problem is number of code lines in the package…

Will update.


Thanks for the update! I’ve also tried uploading an alternative package ( but received the following error message:
Failed to upload node_modules.tar.gz: unknown: Unexpected token (62:14) 60 | } 61 | > 62 | async function* exploreWalkAsync(dir, path, followSyslinks, useStat, shouldSkip, strict) { | ^ 63 | let files = await readdir(path + dir, strict); 64 | for(const file of files) { 65 | let name =;


The dependencies are in beta and far from perfect.

We are working on improving stability and predictability…


1 Like

Any updates on this by any chance?

Hello @Pavel_Duchovny , one more import issue here :slightly_smiling_face:

I am trying to use Sentry SDK in Realm functions. This package depends on tslib. But I cannot import tslib, Realm shows following error:

Failed to upload unknown: Unexpected token (15:36) 13 | // Force a commonjs resolve 14 | import { createRequire } from “module”; > 15 | const commonJSTSLib = createRequire(import.meta.url)("…/…/tslib.js"); | ^ 16 | 17 | for (const key in commonJSTSLib) { 18 | if (commonJSTSLib.hasOwnProperty(key)) {

Does this mean that I better leave the idea to use Sentry SDK in Realm for now?

Hi guys,

I was trying to help on first response but the beta dependencies limitations are not owned by me.

CC @Drew_DiPalma maybe someone from Realm cloud could help…

1 Like

I ran into the same problem. Using SheetJS in Realm functions is very slow. Running the function in the console works, but it takes more than 40 seconds to execute. Most of the time seems to be taken up when calling ‘const XLSX = require(“xlsx”);’.
When calling the very same function from within my android app I run into a timeout (already after 10 seconds). I opened an issue about it:

I tried using exceljs instead, but I get the same error as Ilya.

Would be great to get an update about it, because it is very important for me to be able to send some data as an excel sheet. The sending part with AWS SES works fine. :slight_smile: