Skip to content

project deploy start exits 10 "fetch failed" when the connection closes between status checks; the deploy keeps running #3685

Open

Description

@sanchezcodes

Before You Submit

Command

sf project deploy start (also deploy validate, deploy quick: any command that waits with MetadataApiDeploy.pollStatus)

Org Type

Sandbox

Did this work before?

Not sure

Summary

When Salesforce closes the HTTP connection between two deploy status checks, sf project deploy start --wait N exits 10 with MetadataTransferError: Metadata API request failed: fetch failed, while the deploy keeps running and later succeeds in the org. In CI this marks a successful deploy as failed.

Cause, as far as we can read the code:

  • jsforce-node's fetchWithRetries retries only GET/PUT/HEAD/OPTIONS/DELETE; checkDeployStatus is a SOAP POST, so the request is not retried.
  • source-deploy-retrieve MetadataTransfer.isRetryableError tolerates network errors by matching error.message against ECONNRESET, socket hang up, etc. With undici the message is fetch failed (the cause, SocketError: other side closed, UND_ERR_SOCKET, is in error.cause), so none match and poll() rethrows. Same list in SDR 13.6.0 and 13.12.0.

We saw it 4 times in 20 minutes, from two different machines (GitHub Actions runners and a cloud VM), against the same sandbox, with no Trust incident.

Steps to reproduce

The closure is intermittent; we reproduce it deterministically with a local CONNECT proxy that closes the tunnel of one status check:

  1. Run a CONNECT proxy on 127.0.0.1:18081 that, after ~20 s, closes the next tunnel right after the client sends its request (about 20 lines of Node net; happy to share).
  2. HTTPS_PROXY=http://127.0.0.1:18081 sf project deploy start --dry-run --source-dir force-app/main/default/classes -o <sandbox> --test-level RunSpecifiedTests --tests SomeTest --wait 10 --json

Expected Result

The CLI treats the closed connection as a transient network error (as it does for ECONNRESET), keeps polling, and returns the deploy's final result (exit 0 here).

Actual Result

Exit 10 after the first closed connection:

{"status":10,"name":"MetadataTransferError","message":"Metadata API request failed: fetch failed","data":{"id":"0Af..."}}

The CLI log (~/.sf/sf-YYYY-MM-DD.log) has:

TypeError: fetch failed
    at Object.processResponse (undici/lib/web/fetch/index.js:272:16)
    at async fetchWithRetries (@jsforce/jsforce-node/lib/request.js:111:25)
caused by: SocketError: other side closed
    at TLSSocket.onHttpSocketEnd (undici/lib/dispatcher/client-h1.js:1024:22)

sf project deploy report --job-id <id> afterwards shows the job Succeeded.

Suggested fix

In isRetryableError, also inspect error.cause (and error.cause.cause) for code in UND_ERR_SOCKET, ECONNRESET, ETIMEDOUT, …, or add fetch failed / other side closed to retryableErrors. A status check is read-only, so retrying it is safe.

Our workaround: when the command exits 10 with this error and data.id, we follow the same job with sf project deploy report --job-id <id> --wait <remaining>.

System Information

@salesforce/cli/2.157.8 linux-x64 node-v24.22.2
@salesforce/source-deploy-retrieve 13.11.0, @jsforce/jsforce-node 3.12.0, undici 8.12.3
(also @salesforce/cli 2.156.5: SDR 13.6.0, undici 8.12.2)

Activity

  1. added
    bugIssue or pull request that identifies or fixes a bug
    on Nov 9, 2026
  2. git2gus commented on Nov 9, 2026

    @git2gus

    This issue has been linked to a new work item: W-24844126

  3. k80bowman commented on Nov 9, 2026

    @k80bowman

    Thank you for reporting this, we will take a look.

  4. thvd commented on Nov 13, 2026

    @thvd

    Independently observed the same error during Metadata API deployment status polling. The CLI debug log captured:

    TypeError: fetch failed
        at Object.processResponse (undici/lib/web/fetch/index.js:272:16)
        at async fetchWithRetries (@jsforce/jsforce-node/lib/request.js:111:25)
    caused by: SocketError: other side closed
        at TLSSocket.onHttpSocketEnd (undici/lib/dispatcher/client-h1.js:1024:22)
    

    Successful InProgress status polls immediately preceded the error. The serialised log retained the cause in the stack, but did not expose a structured cause code, so I cannot independently confirm UND_ERR_SOCKET.

    Would you welcome a focused PR to source-deploy-retrieve that recognises transient nested network causes and uses the existing bounded polling retries, preserving the same deployment ID rather than resubmitting the deployment?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions