Error importing external dependencies

I am trying to use SheetJS js-xlsx as an external dependency. I have uploaded it as described in https://docs.mongodb.com/realm/functions/upload-external-dependencies.

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
Pavel

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:

https://docs.mongodb.com/realm/functions/js-feature-compatibility

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

Thanks
Pavel

Thanks, I see. It would be great if you could have a look at the package: https://github.com/SheetJS/sheetjs

@Ilya_Sytchev,

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.

Best
Pavel

Thanks for the update! I’ve also tried uploading an alternative package (https://www.npmjs.com/package/exceljs) 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 = file.name;

@Ilya_Sytchev,

The dependencies are in beta and far from perfect.

We are working on improving stability and predictability…

Thanks
Pavel

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 node_modules.zip: 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