Skip to content

Commit

Permalink
Merge pull request #588 from OpenFn/salesforce-fix-any-ascii-load
Browse files Browse the repository at this point in the history
salesforce: Ensure anyscii is loaded before executing
  • Loading branch information
josephjclark authored May 27, 2024
2 parents 6a59bb2 + 7c4b618 commit d1b5fe4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/salesforce/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-salesforce

## 4.6.8

### Patch Changes

- Properly ensure any-ascii is loaded before executing, resolving a critical
race that we are losing in production

## 4.6.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-salesforce",
"version": "4.6.7",
"version": "4.6.8",
"description": "Salesforce Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"exports": {
Expand Down
9 changes: 5 additions & 4 deletions packages/salesforce/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import { expandReferences as newExpandReferences } from '@openfn/language-common
import jsforce from 'jsforce';
import flatten from 'lodash/flatten';

// use a dynamic import because any-ascii is pure ESM and doesn't play well with CJS
// Note that technically we should await this, but in practice the module will be loaded
// before execute is called
let anyAscii = undefined;
import('any-ascii').then(m => {

// use a dynamic import because any-ascii is pure ESM and doesn't play well with CJS
// This promise MUST be resolved by execute before a connection is created
const loadAnyAscii = import('any-ascii').then(m => {
anyAscii = m.default;
});

Expand Down Expand Up @@ -792,6 +792,7 @@ export function execute(...operations) {
// Note: we no longer need `steps` anymore since `commonExecute`
// takes each operation as an argument.
return commonExecute(
loadAnyAscii,
createConnection,
...flatten(operations),
cleanupState
Expand Down

0 comments on commit d1b5fe4

Please sign in to comment.