[BUG] Code runs twice on a page duplicated from the Menu

Hey guys,

This is the second time I am experiencing this. When you ‘Duplicate’ a page the code on the page runs twice. Which means if I’m submitting a form, the form is inserted 2 times into the database and a confirmation email is sent twice.

Last time (when I did not raise this issue) the page was charging a credit card twice via Stripe (Live Environment) and creating 2 orders, I did not report this because there was more than 1500 lines of code and I thought it was my mistake somewhere but now I am sure this is a bug.

Can someone from the team please take a look at the page where it is occurring.

Shan

1 Like

Sounds super-weird. how can it happen?

I swear its exactly how I’m describing it.

@shantanukumar847 I didn’t say it’s not like that, but it’s a quite unusual bug. Anyway, since it happened twice, and in your case it’s very painful, maybe you should add some code to deal with such bugs (for example to add a click timestamp and reject collection records if the timestamp is not unique).

Sounds serious enough. Following.

[UPDATE]

When you duplicate the ‘duplicated’ page: The code will run 3 times.

Hope someone from the team notices this thread.

Hey Shah, I see that you are not exactly swamped by response and I know how frustating that can be, been there.
Do you have a short proof-of-concept version that I can try out? Or should I make one myself (for nobody is going to look thru 1500 lines of code). Could you give me a few pointers, like:

  1. is it a dynamic page or not (think last, since dynamics can´t be copied, but see 3)
  2. you use a dataset or data-insert
  3. what is your page renaming convention or do you copy across projects
  4. do you use any db-hooks (like onBefore/AfterInsert on db level, so not in code

Let me know, maybe we can narrow it down a bit.

We need more information in order to evaluate this issue. Please provide site URLs, indicate which site page is encountering the problem, and what was the original page that was duplicated.

Hey Yisrael,

Sorry for the trouble but here are the links:

The place where the code runs twice: [REMOVED]
The original page: [REMOVED]

Also, this is not confined to one particular site as its happening on all the sites I work with. To explain to you better I have made the following video.

P.S. Even if I change the Page’s URL or name it still does not solve the issue.

Hey @giri-zano

I have added a video below Yisrael’s comment to help you understand better the use case.

@shantanukumar847 Hey shan, I’m playing with this and so far I don’t see the problem. I created a page, with a button, and a console.log() - just like you did. It works fine - the console.log() output appears once per button click.

I’m still playing with it.

@yisrael-wix Well my horoscope said it will be a pretty rough month for me so…

Any idea why its only me because it has happened on 4 different sites until now.

@shantanukumar847 Did you try it with different browsers? On a different computer? After drinking a different beer?

@yisrael-wix Actually I found out about the problem when Stripe charged a user’s card twice for a single purchase. The user was from Spain using a mobile device.

After this I have run tests on my Windows 10 Laptop, Android Mobile, Android Tablet, MAC, Windows 8.1 Laptop but its the same everywhere.

However I will try to have another kind of beer and let you know.

P.S. In the meantime if you find out anything more about this then please let me know.

Thanks Yisrael

@shantanukumar847 isn’t that the same issue as yours? https://www.wix.com/corvid/forum/community-discussion/bug-sendgrid-api-sending-duplicate-emails-to-same-recipient-email-address

@jonatandor35 Indeed.

I think this is a new feature :joy: :joy: :joy:

Better get used to it.

I can’t reproduce this problem - no way, no how.

But being the good boy that I am, I reported this to QA for evaluation.

This is why I’ll vote for you when you run for president.

@shantanukumar847 :rofl: I’m already working on my campaign slogan… “free beer”.

Well, of course, this is a feature. What? You don’t want the duplicated button to be connected to both the old and new event handlers? Hmm.

The smart people in QA have verified that your suspicions are correct and that the duplicated page does in fact maintain the connections to the event handlers on the original page. They’ve opened up a ticket on this.

Meanwhile, a workaround for this is to disconnect the component on the duplicated page from its event handler (which ends up disconnecting the old event handler as well), and then connect it again to its event handler on the new page. Do this for all affected components.

Wash it all down with a beer.