Creating a new Connection causes an infinite refresh.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 551
- Avg merge
- 9h 2m
- Merged PRs (30d)
- 3
Description
Hello, I have a problem. I am using jsforce version 1.11 on my project. Now I decided to upgrade to version 3 and encountered an error.
My code creates a new connection, passing in a perfectly valid refreshToken and instanceUrl. The passed instanceUrl is valid, but not the one returned by Salesforce.
For example, I have an instanceUrl:
https://mdc-hause.my.salesforce.com
JsForce V1 and Salesforce CLI work with this URL.
I get the following URL when creating a connection:
https://someKey-playground1.my.salesforce.com
Note: These URLs are provided as an example to show that they are the same org. Salesforce previously replaced one with the other, so they both work. However, JsForce V3 doesn't work with the older one.
However, when attempting to make a request on this connection, the .on('refresh') event is called indefinitely:
const creds = {
oauth2: {
validClientId,
validClientSecret,
},
refreshToken: validRefreshToken,
instanceUrl: validProperInstanceUrl,
version: '60.0',
};
connection = new jsforce.Connection(creds);
connection.on('refresh', (accessToken) => {
console.log('instanceUrl', connection.instanceUrl);
// Here, the connection already has an refreshed instanceUrl. This log is reproduced endlessly.
});
const q = connection.query(someQuery)
.on('record', (record) => {
records.push(record);
})
.on('end', () => {
resolve(records);
})
.on('error', (error) => {
reject(error);
});
console.log('Before query run');
q.run(JSFORCE_OPTIONS)
.catch((err) => {
reject(err);
});
However, when I try to execute the request, the 'refresh' event occurs again and again, and the request fails. In the terminal, I see the following:
Before query run
instanceUrl https://someKey-playground1.my.salesforce.com
instanceUrl https://someKey-playground1.my.salesforce.com
instanceUrl https://someKey-playground1.my.salesforce.com
instanceUrl https://someKey-playground1.my.salesforce.com
instanceUrl https://someKey-playground1.my.salesforce.com
......
Note: The above code works for jsforce V1.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the new Connection refresh flow and the query request shown in the issue, reproducing the case with an older valid instanceUrl that Salesforce replaces. Compare the jsforce v1 and v3 behavior; done means the refresh event occurs once and the request completes instead of looping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100