How to test a Server Side plugin?

Or rather … how do I see the output from the plugin running ?

At the moment it does … nothing. But I can’t see what error it is producing.

Plugin is setup, and is firing from the test app … but then no response.

Any thoughts ?

I’ve not yet tried it myself, but I did come across this and this.

console.log(String);

It will output the log in the workflow log system.

Thanks. But where :slight_smile:

In the code of the server side action of the plugin.

If you want to test it out quickly and see how the log looks like use the ssa from Misha’s toolbox.

Or you mean the verbose output of the error you think the plugin is spitting?

I am not sure what I mean :slight_smile:

client.post(‘statuses/update’, status, function(error, tweet, response) {
if (!error) {
return {
out: JSON.stringify(response)
}
}else{
console.log(error)
}

Nothing appears in either the Bubble Log or the Console Log … so not quite sure what I am doing wrong.

If it’s a SSA you can discard completely finding something in the browser console.

I’m on mobile so I can’t send you a screenshot of how it looks in the logs tab. I can say it looks ugly and it is in the middle of a long string. I think also that with the last change you can now filter in the logs tab so you can only see the strings that have a console.log output.

What I am saying is that you may be missing the console log because the log is empty and in the middle of a string of gibberish.

Plugin server side action console output

START RequestId: 603be3e7-cc98-4d8b-a06d-f2adaa1bb6c5 Version: $LATEST END RequestId: 603be3e7-cc98-4d8b-a06d-f2adaa1bb6c5 REPORT RequestId: 603be3e7-cc98-4d8b-a06d-f2adaa1bb6c5 Duration: 241.76 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 73 MB

Yeah that is the one. There doesn’t seem to be an error there.

Change the console.log(error) to console.log(“this is a console log”) and it should not print anything.

Aha, so it may not be erroring, it may just not be “working”.

1 Like

Oh, if I had a nickel for every time I said that!

For reasons unknown it just skips all the way through until the line before the last }

The closing “}” is missing.

Is there anything I can stuff the JS into to give a visual representation of the structure ?

There are too many }s for my limited skill.

A missing } or any other syntax error would most probably spit something in the browser Bubble debugger box in debugging mode.

1 Like

Hey Nigel…

I use notepad ++ on a pc which helps you see your bracket levels…

Then I used various online tools for syntax checking like is jslint…

And also created a client side equivalent of my plugin (so one done with an element) and found a way to easily swap code between the client and server side version… Then with the client side one I had easy console.logging and an almost accurate description of the line number that was causing the problem… and of course for testing, it executes in milliseconds rather than nearly 12 seconds! Here is the code framework:

function(instance, properties, context) {
var actiontype = "element"; // element or server
// Function call for element:
// function(instance, properties, context) {
// Function Call for server:
// function(properties, instance) {  
 
// GET the single item inputs but only needed if running on the server.
if (actiontype == "server") {
  if(properties.this_input) {properties.this_input.get();} 
  // etc etc
}

////////////////////////////////////////
// DO ALL YOUR FUNKY JAVASCRIPT WORK...
////////////////////////////////////////

//Output
  
if (actiontype == "element") {
  instance.publishState("this_output", this_output_value);
  // etc etc
}
  
if (actiontype == "server") {
  return {"this_output":this_output_value};

}

Couple of things to look out for:

  1. The first line with the function call needs to be absolutely the same text as Bubble provides, without a space or anything different.
  2. The line number with the problem when testing the element based client side version is the number shown in the anonymous bit of the message -2!

Good luck!
Antony. :slight_smile:

2 Likes

What do you log if you try this,

client.post(‘statuses/update’, status, function(error, tweet, response) {
if (!error) {
console.log({error: error, tweet: tweet, response: response});
return {
out: JSON.stringify(response)
}
}else{
console.log(error)
}

Hey @NigelG, I discovered that pressing Shift+Tab auto-formats selected code, making it easier to identify unbalanced code blocks.

bubble-code-format

(Also note the disclosure triangles to the left which expand/collapse blocks of code.)

That said, while it’s definitely handy to have some limited syntax highlighting, code formatting, and code completion directly in the browser, there’s no substitute for a full-featured IDE. (Hard to imagine a time when “real coders” developed software without the aid of such tools!) Unfortunately, it’s not easy to integrate an external IDE into a Bubble plugin dev workflow in my experience. If anyone has found a good approach, I’d be interested to hear about it.

3 Likes

Hi again Nigel… I just updated my post above to include the code! :slight_smile:

1 Like

I used to code on a coding “sheet” and hand test it. Because the compiler only ran overnight and you didn’t want a syntax error at 9am if you had to wait 24 hours :slight_smile: