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

Unsettled top-level await at sf force data bulk upsert #3180

Closed
pawel-id opened this issue Jan 15, 2025 · 7 comments
Closed

Unsettled top-level await at sf force data bulk upsert #3180

pawel-id opened this issue Jan 15, 2025 · 7 comments
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated

Comments

@pawel-id
Copy link

Summary

Salesforce CLI upsert command is failing on node.js v22 due to unsettled top-level await. Problem is not happening on node.js v20 or lower.

Steps To Reproduce

The problem can be replicated on any scratch org or sandbox. The simplest way is to use empty scratch org as provided below.

Clone repository https://github.com/pawel-id/unsettled and use its content in replication steps

  1. Check prerequisites:

    • node.js v22
    • @salesforce/cli/2.71.6
    • provide DevHub for scratch org creation
  2. Create scratch
    sf org create scratch -f config/project-scratch-def.json -v devhub -w 10 -a scratch

  3. Deploy the custom object sf project deploy start -o scratch

  4. Upsert some data
    sf force data bulk upsert -f data/ProductExternalData.csv -s ProductExternalData__c -i MaterialCode__c -w 15 -r -o scratch

Expected result

Graceful exit returning code 0

Actual result

On node.js 22 or later the upsert command finishes with an error and returns code 13:

Bulk Upsert... ⢿
Warning: Detected unsettled top-level await at file:///Users/pawel/.nvm/versions/node/v22.11.0/lib/node_modules/@salesforce/cli/bin/run.js:15
await cli.run();
^

The error will not happen when using node.js v20 or lower instead of v22.

Additional information

The object and upserted data represent anonymised data from environment where this issue was originally encountered. It might be possible to create simpler replicable scenario.

Similar problem has been reported here #3112

System Information

Problem has been replicated on macos with bash and linux. Windows wasn't tested however it is expected to behave the same.

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.71.6",
  "nodeVersion": "node-v22.11.0",
  "osVersion": "Darwin 24.2.0",
  "rootPath": "/Users/pawel/.nvm/versions/node/v22.11.0/lib/node_modules/@salesforce/cli",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.14 (core)",
    "@oclif/plugin-commands 4.1.14 (core)",
    "@oclif/plugin-help 6.2.19 (core)",
    "@oclif/plugin-not-found 3.2.31 (core)",
    "@oclif/plugin-plugins 5.4.22 (core)",
    "@oclif/plugin-search 1.2.17 (core)",
    "@oclif/plugin-update 4.6.18 (core)",
    "@oclif/plugin-version 2.2.18 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.28 (core)",
    "@oclif/plugin-which 3.2.21 (core)",
    "@salesforce/cli 2.71.6 (core)",
    "apex 3.6.8 (core)",
    "api 1.3.2 (core)",
    "auth 3.6.82 (core)",
    "community 3.3.6 (user) published 46 days ago (Sat Nov 30 2024) (latest is 3.3.8)",
    "data 3.13.5 (core)",
    "deploy-retrieve 3.16.0 (core)",
    "info 3.4.29 (core)",
    "limits 3.3.43 (core)",
    "marketplace 1.3.7 (core)",
    "org 5.2.11 (core)",
    "packaging 2.9.7 (core)",
    "schema 3.3.45 (core)",
    "settings 2.4.9 (core)",
    "signups 2.6.8 (user) published 39 days ago (Sat Dec 07 2024) (latest is 2.6.10)",
    "sobject 1.4.46 (core)",
    "telemetry 3.6.27 (core)",
    "templates 56.3.34 (core)",
    "trust 3.7.51 (core)",
    "user 3.6.5 (core)",
    "@salesforce/sfdx-scanner 4.7.0 (user) published 78 days ago (Tue Oct 29 2024) (latest is 4.8.0)",
    "sfdmu 4.38.0 (user) published 17 days ago (Sun Dec 29 2024)",
    "sfdx-git-delta 5.52.0 (user) published 22 days ago (Mon Dec 23 2024) (latest is 6.1.0)"
  ]
}
@pawel-id pawel-id added the investigating We're actively investigating this issue label Jan 15, 2025
Copy link

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.

@github-actions github-actions bot added the validated Version information for this issue has been validated label Jan 15, 2025
@mdonnalley
Copy link
Contributor

@pawel-id thanks for posting this. I was able to replicate it so I'll mark it as a bug

@mdonnalley mdonnalley added bug Issue or pull request that identifies or fixes a bug and removed investigating We're actively investigating this issue labels Jan 15, 2025
Copy link

git2gus bot commented Jan 15, 2025

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

@cristiand391
Copy link
Member

@pawel-id we got a fix for this currently in review ⬆
current workaround:
do an async upsert (no --wait), then manually check the job status in the org.

If you don't really need insertions to be in serial we suggest using the data upsert bulk command which uses the Bulk 2.0 API and has been recently revamped.

@pawel-id
Copy link
Author

@cristiand391 Thank you! We need --wait because, in our application, it is part of continuous integration, where this upsert must be completed before the next step. However, this might still be useful for someone else.

For our particular case, it looks like there is a better option. It turns out we actually don't need --serial. We followed your advice and tried data upsert bulk. It required some tweaks for edge cases, but it works promising.

@cristiand391
Copy link
Member

cool!
The fix for this was included in sf v2.75.5 (currently RC, will be promoted to stable on Feb. 5)
https://github.com/forcedotcom/cli/tree/main/releasenotes/#2755-feb-5-2025-stable-rc

@jshackell-sfdc
Copy link
Collaborator

This bug is fixed in 2.75.5 (Feb 5, 2025).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

4 participants