Backendless Support
 
Solved

business logic deploy

It appears I'm getting an error while trying to debug my service. The error is on Backendless.ServerCode.addService(EmailService);

According to what I read the debug version should superceed the deployed version but it kept running the deployed version. So, I then stop the deployed version but it was still being used.

Do I need to change the version number when testing a new version?

10:12:44.305 - CodeRunner(tm) Backendless JavaScript CodeRunner v4.4.4

10:12:44.307 - Copyright(C) 2018 Backendless Corp. All rights reserved.

10:12:44.406 - Starting Debug Code Runner...

10:12:44.406 - Building Model..

10:12:45.159 - Model Build completed

10:12:45.160 - Services (1):

10:12:45.160 - EmailService (deploy/services/emailService.js)

10:12:45.160 - Errors (1):

10:12:45.160 - [EmailService] service already exists (services/emailService.js:66:24)

10:12:45.247 - Registering Code Runner on https://api.backendless.com

10:12:45.457 - Runner successfully registered.

10:12:45.458 - Registering Model on https://api.backendless.com

10:12:45.797 - Model successfully registered

10:12:45.797 - Waiting for Server Code tasks..

Leave a Comment

Comments (11)

photo
1

Do you see any debug/production services on console?

photo
1

please provide your applicationId

photo
1

C25CB2C7-149D-F6DC-FF86-AEE62D080B00

socialteetimev2

photo
1

I don't see any services neither in your app, nor in the database. Have you managed to solve this problem yet?

Probably you accidentally defined the EmailService twice on emailService.js:66 ?

photo
1

No, I have't been able to.

photo
1

Here's my code. It's in flux but there's nothing to it.

'use strict';

class EmailService {

/**

* @param {string} data

* @param {string} SENDGRID_API_KEY

*/

sendEmail(data, SENDGRID_API_KEY) {

/* const sgMail = require('@sendgrid/mail');

//sgMail.setApiKey(process.env.SENDGRID_API_KEY);

sgMail.setApiKey(SENDGRID_API_KEY);

sgMail.setSubstitutionWrappers('-', '-'); // Configure the substitution tag wrappers globally

sgMail.send(data, true)

.catch((err) => {

console.log('EmailService sendEmail error', err);

}); */

//var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);

var sg = require('sendgrid')(SENDGRID_API_KEY);

var request = sg.emptyRequest({

method: 'POST',

path: '/v3/mail/send',

body: {

personalizations: [

{

to: [

{

email: 'daniel.p.spring@gmail.com'

}

],

subject: 'Sending with SendGrid is Fun'

}

],

from: {

email: 'daniel.p.spring@gmail.com'

},

content: [

{

type: 'text/plain',

value: 'and easy to do anywhere, even with Node.js'

}

]

}

});

// With promise

sg.API(request)

.then(function (response) {

console.log(response.statusCode);

console.log(response.body);

console.log(response.headers);

})

.catch(function (error) {

// error is an instance of SendGridError

// The full response is attached to error.response

console.log(error.response.statusCode);

});

}

}

EmailService.version = '1.0.0';

Backendless.ServerCode.addService(EmailService);

photo
1

Is there another file in the same deployment which also calls .addService with the same name?

photo
photo
1

I first deployed yesterday and I had no issues (that I saw) running a debug version over the deployed version. Today i received an email that I was over the size threshold and not I get this error. I can't image there's a correlation between the size and being able to run/debug a new version.

photo
1

hmmm, i don't think so but a good idea. Let me look.

photo
1

You nailed it. I don't know why but there was another directory in my project named deploy with a duplicate set of code. I deleted it and was able to run my project as expected. Thanks for the help.

photo
1

Glad you solved it. You're welcome!

photo