[New Feature] Server side actions now support node modules

Howdy, @marca. Any update on this (server side action speed)? I find that my minimal test app (which uses my published minimal server-side action “Return 5”) is still really slow to return its values.

Is the situation here simply that Bubble apps are allocated extremely minimal CPU time? If so, that’s a shame as server-side actions hold a lot of promise for extending the core functionality of Bubble, but they’re just not performant enough that anyone would find a published SSA plugin useable/worth paying for…

That app is this one, BTW (“Return 5”):

Testing from my side. It sounds to be never the same values. Something is limiting the process. Refresh your page and see other results.
part 1: 30 sec., 5 sec, 2 sec! (server side) , on AWS windows server: less then 2-3 sec. (good)
part 2: 5 sec., 30 sec, 5 sec. (direct)
part 3: less than 1 sec. (other api call)

So, the two buttons at top just trigger the “Return 5” SSA (which is just a minimal function that always returns the integer 5). Since the test app is a freebie, you’ll see these complete in a very wide array of times depending upon what resources are available on the free cluster. (You will sometimes see them complete instantaneously, but sometimes take many many seconds – as you discovered.)

The bottom button calls essentially the same function running as a Webtask via the API Connector. (This takes a consistent amount of time – around 1 second – all of which is Bubble API Connector overhead, really.)

My point with this demo app is that SSAs – while very exciting – seem essentially unusable for most things one would think to do with them.

The situation is not better on a reserved capacity plan, BTW. What you tend to see is more consistency in the amount of time it takes for the plugin to return, but they are still very slow. I’ve experimented up to 7 units of capacity and that’s still not enough for a decent experience.

1 Like

The amount of capacity will make no difference (even 40 units). The problem sound’s to be on ‘immediate’ processing.

@keith, this is the top of my priority list as of tomorrow morning. I’m reluctant to commit myself to a timeframe, but a significant improvement to server side action performance is forthcoming in the near future. I’ll keep you guys posted.

7 Likes

Cool. Thanks, @marca.

Hi Marca,
After listed the “dateformat” depenency just like what you showed in the snapshot or as follow:

{
“dependences”: {
“dateformat”: “3.0.0”
}
}

How exactly are we supposed to import this module ??? I tried the following:

function(properties, context) {

var dateFormat = require('dateformat');

}

But that doesn’t work, the browser saying “cannot find this module on the server”. So could you please let us know how you import the any node modules? I know that all the current node modules are not exposed due to some reason, but could you just let us know how to import these modules to get us start using this new feature. There is absolutely no other documentation about this on the bubble website, it has been very frustrating. I sent an email to ask for help and also no one replied. So could you do everyone a favour to explain this a bit clearer.

Many Thanks
Steve

2 Likes

Having issues here too, folllowing.

Thanks so much! It is amazing!

1 Like

An ordinary import statement like that ought to work. Where are you getting that error message?

I’ll put up some improved documentation.

1 Like

Hi @marca, discovered a somewhat tweaky issue with server-side actions and node modules when working on my set of actions over the weekend. I’ve got an action that leverages moment timezone and moment range to divide a range up into individual date objects that represent intervals in that range (e.g., given a range from Jan 1 - Jan 31, return dates for the individual days within that range).

This works fine (albeit very slowly, as we know), but I while programming and testing that I did hit a situation where my code was doing something incorrect, but instead of the whatever error (that I assume moment-range would have generated in this particular case) “bubbling up” to the workflow level, the action simply timed out (I got error such-and-such action timed out after 10.01 seconds message).

This is one of those things where I’d have to run the code in question somewhere else (either locally or on something like Webtask) to see what exact error (if any) was being thrown, but I wanted to mention this as a potential issue. (I’ll try to make a simple reproducible case, and if I can, will log that as a bug.) I’d be surprised if moment-range was actually silently failing in this particular case, rather than throwing an error.

And I hope you are making progress on speed issues vis-a-vis server-side actions! (Iteratively testing even simple actions remains quite painful as they simply take so long to return. (I know you know this, but FYI.)

Best Regards,
Keith

Thanks for the idea. A “debug mode” for server side actions, which would allow plugin developers to see console output of the functions they are building, is definitely something we’re discussing. We’ll keep you posted.

6 Likes

Hey @marca, yeah that would be super-helpful. (Like if there were a variation on console.log.) Presently what I do if I need to check some intermediate state is just return with the debug info or add that to the return, but obviously that takes a bit of work.

Thank you Marca. It was my silly mistake to spell the “dependencies” incorrectly in my last post.

UPDATE: In the interests of making this feature a bit easier to use, we’ve just added a neat little bit of functionality that automatically adds modules to your package.json from your require statements. When you click away from the code editor, your package.json will automatically update, adding any packages not already present that you’ve required. Delete the require statement and the package will go away, if it was automatically added.

8 Likes

That’s kind of crazy. Very deep implementation of NPM. Now… about that speed issue… :wink:

1 Like

Hey @keith

I have published a plug-in couple of days ago that doesn’t this splitting.

It’s called Time

Maybe it can help

Sorry, @AliFarahat, I don’t understand your message?

We fixed the bug that was causing server side actions to frequently take forever. If anyone encounters any further problems, please let me know!

5 Likes

Oh man… checking that out… And, YEP, SSAs now return with a lot more alacrity… and they beat API call to webtask:

One can test here:

1 Like