3

I'm trying to prove out a basic JSforce library use case in Node.js. I'm able to connect to Salesforce, but for some reason, I'm unable to run a basic query.

  • Node version: v16.13.0
  • jsforce version: 1.10.1
  • OS: Windows 10 Enterprise version 1909

Repro code:

import jsforce from "jsforce";
import dotenv from "dotenv";
let SF_USERNAME, SF_PASSWORD;

const runTest = async () => {
  dotenv.config();
  ({ SF_USERNAME, SF_PASSWORD } = process.env);

  // Outputs my username correctly
  console.log("SF_USERNAME: " + SF_USERNAME);

  const config = { loginUrl: "https://test.salesforce.com" };
  const conn = new jsforce.Connection(config);
  await conn.login(SF_USERNAME, SF_PASSWORD);

  // Outputs my user ID correctly
  console.log("Authenticated User ID: " + conn.userInfo.id);

  // When I uncomment the 3 lines below, my terminal freezes indefinitely
  // const { totalSize, records } = await conn.query(
  //  "SELECT Id, Name FROM Account LIMIT 3"
  // );
};

runTest();

I'm using $ node src/test.js in Git Bash to execute this. I have also tried using the old CommonJS syntax (i.e. const jsforce = require("jsforce");) and running the code as a CommonJS script, with the same results.

It all seems straightforward enough. What am I doing wrong?

1

1 Answer 1

4

@identigral had a good guess, and that StackOverflow article seemed like it might be on to something. But in the end, the root cause was something less obvious.

This root problem turned out to be that my Salesforce password had expired (the audience groans). Once I reset my password, everything (including the async/await syntax in my sample code) started working just fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .