JS Parse Errors When Submitting A New Version

Hey there experienced plugin builders… so I’ve spent a week beavering away at my javascript which now runs perfectly when my plugin is in test mode. I go to “Submit a New Version” and I get the message:

js%20error

Can you recommend the best external tool to check my code with?

I have both a server action and an element action.
I’ve tried Esprima: Syntax Validator, and the code passes, but still fails to “Submit” in the plugin editor.

Thanks!
Antony.

Same error here, did you manage to solve it by any chance?

Good question! It was a while ago now… I recall that I put my Javascript through various syntax checkers and found some bits of syntax weren’t entirely correct… and I also found that Bubble is very sensitive about the format of the opening function call line… things like extra spaces which you wouldn’t usually expect to be an issue… so maybe create a new empty action and just check that opening line is exactly the same…

Good luck! :slight_smile:

2 Likes

After weeks of building my plugin I’m also stuck with this… @antony @akieffer any more advice?

Check your actions. Put them thru a traditional code editor like vscode or jsfiddle to help find code errors

I’ve tried and everything seems ok apart from the first line because the function is not defined.

function(properties, context) {

thanks,

Phill

Well…
If that’s the only line then your missing an ending bracket too.

Ha, I wish my plugin was that simple… Have you had this error before when publishing a plugin? What did you do to fix it?

For me, this always means I have messed up some braces { } somewhere - effectively a JS error. I basically just comment out code and open up the editor in full screen and close (which seems to make the editor re-evaluate the js code) until I find the naughty or missing brace.

1 Like

Thanks for the suggestion, I’ve just tried this as well as validating my code in VS Code and online validators. No curly braces missing and no validation errors! I have no idea where to go next with this :confused:

Want a second pair of eyes on the code?

1 Like

Thanks for the offer, I may take you up on that. In the meantime, I’ve put in a support ticket with Bubble so lets see what they come back with.

All sorted! Bubble support had a look and found that when you changed one of my actions from server-side to client-side, the code had a duplicate ‘function(properties, context) {’ for some bizarre reason.

1 Like

Hi,
I had this issue happen to me to. I started out with a client action, but I decided to change for a server action. When I did it, I just cut and pasted my code from run_client to run_server… this means that run_client section stayed empty. Even though it is not used (and not displayed in the UI) it causes the error.

I switched to client action, pated the default code and switched back to server code, this resolved the issue. the default code for run_client is:

function(properties, context) {

//Load any data

//Do the operation

}

Eldad

2 Likes

Just to close this thread forever:

Bubble’s first line of JavaScript in the plugin builder (all places, pretty much) IS NOT VALID JS.

Obviously what they do is look for a specific string. That string being:

"function("… etc.

Of course, function( is not valid JavaScript. There should be a function name or at least a space. The first line is just a “prompt” for you saying “write your shit here”.

This IS insanely annoying as your “code” won’t pass any linter due to this unusual syntax. But just know that it’s not really your code. It’s just how Bubble figures out where your function begins.

They could have done this in a better way, but this is just the way it is.

1 Like

Also, “Dear Bubble, quit being stupid. Thanks, Keith”.

1 Like

Thank you very mach!

this is a solution

This solved it for me… omg… pffff