Skip to content

Unhandled SocketError: other side closed from undici HTTP/2 client crashes long-running data commands #3622

Closed

Description

@torynet

Summary

Since @jsforce/jsforce-node moved to undici 8.x, all Salesforce API traffic negotiates HTTP/2 by default (undici 8 changed the default of allowH2 from false to true). When Salesforce closes the HTTP/2 connection during a long-running command (idle timeout / GOAWAY mid-import), the resulting socket error is emitted as an unhandled 'error' event and the entire Node process crashes. Long sf data import tree runs cannot complete.

Steps To Reproduce

  1. sf data import tree --plan <plan.json> with a large plan (~51,000 records across 7 sObjects, roughly a 20-minute import) against a sandbox.
  2. Partway through the import (observed anywhere from seconds to ~12 minutes in), the process crashes.

Because the crash is an unhandled exception, --json produces no output at all — the command dies silently from a script's perspective, with only the Node crash dump on stderr.

Actual result

node:events:486
      throw er; // Unhandled 'error' event
      ^

SocketError: other side closed
    at TLSSocket.onHttp2SocketEnd (...\@salesforce\cli\node_modules\@jsforce\jsforce-node\node_modules\undici\lib\dispatcher\client-h2.js:602:22)
    at TLSSocket.emit (node:events:520:35)
    at endReadableNT (node:internal/streams/readable:1701:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ClientHttp2Stream instance at:
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  code: 'UND_ERR_SOCKET',
  ...
}

Expected result

The import completes, or at minimum the connection-closed error is caught and surfaced as a normal command error (ideally retried, since it is a transient transport condition).

Analysis

  • undici 8 enables HTTP/2 by default: lib/core/connect.js — allowH2 = allowH2 != null ? allowH2 : true. undici 7 defaulted to false.
  • @jsforce/jsforce-node (3.10.18/3.10.19, dependency undici: ^8.5.0) never passes allowH2 and does not handle the 'error' event undici's h2 client emits when the server closes the connection, so the error escapes to the process level.
  • Confirmed by workaround: patching the bundled undici to allowH2 = false (forcing HTTP/1.1) makes the identical 51k-record import complete cleanly, first try.
  • Note: pinning an older CLI version does not avoid this, because npm re-resolves jsforce-node's undici ^8.5.0 range at install time.

Suggested fix

Either pass allowH2: false in jsforce-node's undici dispatcher options until h2 error handling is robust, or attach an error handler for UND_ERR_SOCKET on h2 streams and retry/surface it as a request error. (Likely belongs in jsforce/jsforce — filing here first since sf data import tree is the user-facing failure.)

System Information

  • Shell: PowerShell 7 / Git Bash
  • OS: Windows 11 Home 10.0.26200
  • sf --version: @salesforce/cli/2.146.3 win32-x64 node-v24.10.0 (also reproduced on a fresh npm install of 2.142.6, which resolves the same jsforce-node/undici versions)
  • @jsforce/jsforce-node: 3.10.19 (2.146.3) / 3.10.18 (2.142.6), both with undici 8.5.0
  • Node: 24.10.0, npm 11.6.1

Activity

  1. added
    investigating
    on Aug 10, 2026
  2. github-actions commented on Aug 10, 2026

    @github-actions

    Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

  3. github-actions commented on Aug 10, 2026

    @github-actions

    Hello @torynet 👋 It looks like you didn't include the full Salesforce CLI version information in your issue.
    Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

    A few more things to check:

    • Make sure you've provided detailed steps to reproduce your issue.
      • A repository that clearly demonstrates the bug is ideal.
    • Make sure you've installed the latest version of Salesforce CLI. (docs)
      • Better yet, try the rc or nightly versions. (docs)
    • Try running the doctor command to diagnose common issues.
    • Search GitHub for existing related issues.

    Thank you!

  4. added
    more information required
    and removed
    investigating
    on Aug 10, 2026
  5. torynet commented on Aug 10, 2026

    @torynet
    Author

    Sorry. I didn't provide the full output. Here it is.

    {
    "architecture": "win32-x64",
    "cliVersion": "@salesforce/cli/2.146.3",
    "nodeVersion": "node-v24.10.0",
    "osVersion": "Windows_NT 10.0.26200",
    "rootPath": "C:\Users\telar\AppData\Roaming\npm\node_modules\@salesforce\cli",
    "shell": "powershell.exe",
    "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.54 (core)",
    "@oclif/plugin-commands 4.1.61 (core)",
    "@oclif/plugin-help 6.2.55 (core)",
    "@oclif/plugin-not-found 3.2.90 (core)",
    "@oclif/plugin-plugins 5.4.86 (core)",
    "@oclif/plugin-search 1.2.54 (core)",
    "@oclif/plugin-update 4.7.56 (core)",
    "@oclif/plugin-version 2.2.52 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.70 (core)",
    "@oclif/plugin-which 3.2.59 (core)",
    "@salesforce/analytics 1.4.55 (user) published 197 days ago (Sat Jan 24 2026) (latest is 1.4.79)",
    "@salesforce/cli 2.146.3 (core)",
    "agent 1.45.0 (core)",
    "apex 3.9.40 (core)",
    "api 1.3.54 (core)",
    "auth 4.4.9 (core)",
    "code-analyzer 5.9.0 (user) published 194 days ago (Tue Jan 27 2026) (latest is 5.15.0)",
    "data 4.0.115 (core)",
    "deploy-retrieve 3.24.61 (core)",
    "info 3.4.155 (core)",
    "limits 3.3.106 (core)",
    "marketplace 1.3.44 (core)",
    "org 5.11.26 (core)",
    "packaging 2.30.6 (core)",
    "schema 3.3.131 (core)",
    "settings 2.4.101 (core)",
    "signups 2.6.56 (user) published 246 days ago (Sat Dec 06 2025) (latest is 3.0.3)",
    "sobject 1.4.125 (core)",
    "telemetry 3.8.33 (core)",
    "templates 56.20.0 (core)",
    "trust 3.8.43 (core)",
    "user 3.10.9 (core)",
    "mo-dx-plugin 0.3.2 (user) published 2157 days ago (Sat Sep 12 2020) (latest is 1.2.0)",
    "sfdx-git-delta 6.28.0 (user) published 202 days ago (Mon Jan 19 2026) (latest is 6.45.1)",
    "sfdx-hardis 6.24.0 (user) published 189 days ago (Sun Feb 01 2026) (latest is 7.23.0)"
    ]
    }

  6. added
    investigating
    validated
    and removed
    more information required
    on Aug 10, 2026
  7. soridalac commented on Aug 10, 2026

    @soridalac
    Member

    Hi @torynet , thanks for reporting and for the thorough analysis! I'll get a ticket created to get it fix. Thanks!

  8. added
    bug
    on Aug 10, 2026
  9. git2gus commented on Aug 10, 2026

    @git2gus

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

  10. FedeAbella commented on Aug 14, 2026

    @FedeAbella

    I can add this doesn't only happen on data commands. We've been having this issue multiple times a day on ADO pipelines when running sf project deploy resume

  11. iowillhoit commented on Sep 17, 2026

    @iowillhoit
    Contributor

    This has been released, let us know if you are still having issues

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

    buginvestigatingvalidated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions