Repository navigation
fix: switched from node-fetch to native fetch API @W-23121570@ - #1807
Conversation
6d9dc0c to
f008cdb
Compare
|
Nice. For anyone that needs a workaround right now before this lands... import jsforce from "jsforce";
/**
* Workaround for jsforce#1806. Node 24.17.0 made keep-alive the default for the global HTTP
* agents, and jsforce's bundled (unmaintained) node-fetch@2 hangs forever reusing those
* sockets, so every Salesforce request times out. Forcing `Connection: close` gives each
* request a fresh socket, which sidesteps it. Delete this file once jsforce#1807 ships and we
* bump jsforce.
*/
type Connection = InstanceType<typeof jsforce.Connection>;
export async function createSalesforceConnection(
username: string,
password: string,
): Promise<Connection> {
const connection = new jsforce.Connection({});
const transport = connection._transport;
const originalHttpRequest = transport.httpRequest.bind(transport);
transport.httpRequest = (req, options) => {
req.headers = { ...req.headers, connection: "close" };
return originalHttpRequest(req, options);
};
await connection.login(username, password);
return connection;
} |
b9373b2 to
454bcfe
Compare
| if (err instanceof AbortError) { | ||
| (err as Error).message += ' Request was aborted due to timeout of 10 minutes.'; | ||
| let throwableError: Error; | ||
| if (err instanceof DOMException && err.name === 'AbortError') { |
There was a problem hiding this comment.
DOMException's message property is not editable, so we just need to construct a new one in this case.
| with: | ||
| max_attempts: ${{ inputs.attempts }} | ||
| command: npm install -g @salesforce/cli@nightly --omit=dev | ||
| command: npm install -g @salesforce/cli@dev --omit=dev |
| @@ -236,8 +236,8 @@ | |||
| "https-proxy-agent": "^5.0.0", | |||
There was a problem hiding this comment.
I'm not sure if we're using https-proxy-agent anymore now
| (err as Error).message += ' Request was aborted due to timeout of 10 minutes.'; | ||
| let throwableError: Error; | ||
| if (err instanceof DOMException && err.name === 'AbortError') { | ||
| throwableError = new DOMException((err as Error).message + ' Request was aborted due to timeout of 10 minutes.', (err as Error).name); |
There was a problem hiding this comment.
my claude is saying default timeout is 30 mins?
| message: 'Invalid AiEvaluation identifier' | ||
| })) | ||
| const pool = mockAgent.get(loginUrl); | ||
| pool.intercept({ path: '/services/data/v59.0', method: 'GET' }).reply(429, JSON.stringify({ |
There was a problem hiding this comment.
my claude is saying:
- Test error mocks may not match undici's error wrapping — test/http-api.test.ts:104,116,135 — The retry logic expects
TypeError → cause → SocketError → cause → {code}, but replyWithError(Object.assign(new Error('ECONNRESET'), {code:
'ECONNRESET'})) produces a flat error. If tests pass, it's because undici's MockAgent wraps these into TypeErrors, but
this is fragile and implicit.
There was a problem hiding this comment.
I tried wrapping it in a TypeError and that didn't work, so I think it might actually be correct for it to be unwrapped here. Regardless, I kind of don't want to mess with something that's currently working right now, it that makes any sense.
There was a problem hiding this comment.
one more, I don't think we're using nock anymore either, could be worth it to remove and regen package-lock.json after too
There was a problem hiding this comment.
Oh, good catch. I'll pull that one too.
|
Thanks for fixing this, guys! |
Should close #1806 and forcedotcom/cli#3586