Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any connection events ? #1372

Open
bacloud23 opened this issue Oct 19, 2023 · 1 comment
Open

Any connection events ? #1372

bacloud23 opened this issue Oct 19, 2023 · 1 comment

Comments

@bacloud23
Copy link

bacloud23 commented Oct 19, 2023

I would like to implement a retry mecanism,
I assume Jsforce.Connection is the object to start with.

I see it extends a EventEmitter.. So what I'm trying (expecting in a way) is something like this:

connection.on('connection', function () {
  this.logger.log('@@@@@ Connected to Salesforce @@@@');
});

connection.getConnection().on('disconnect', function () {
  this.logger.log('@@@@@ Disconnected from Salesforce @@@@');
});

// there is only 'connection:new' being emitted in the code as far as I searched, but it does not work neither

I don't know if these are events proposed by JSForce, these are not typed,
Furthermore Is this the right way ? to handle reconnections ?

Thanks to everyone in advance.

@cristiand391
Copy link
Member

hey, sorry for the late reply, triaging old issues.

the connection:new event is emitted when creating an instance of Connection on the jsforce class, not on API requests.
Were you trying to handle network errors? If so, jsforce v3 added support for retrying on common network errors:

'ECONNRESET',

connection:new

jsforce.emit('connection:new', this);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants