An import preview runs asynchronous checks for several warehouse requirements. Someone writes checks.every(async check => check()). Even a check that eventually returns false can appear to pass: the predicate returns a Promise object, which is truthy, rather than its eventual Boolean result.
For a Shopify 3PL review tool, wait for the checks to settle before making the batch decision. The every() predicate contract is synchronous; it tests the immediate return value. Awaiting the Boolean returned by every() afterward does not make its callbacks asynchronous-aware.
Preserve a result for each requested check
This helper accepts a nonempty list of read-only check functions. It validates the list before starting them, then distinguishes a failed check, a rejected check and a result that violates the Boolean contract. It performs no order writes or automatic retries.
'use strict';
const assert = require('node:assert/strict');
async function reviewChecks(checks) {
if (!Array.isArray(checks) || checks.length === 0) {
throw new Error('Nonempty check list required');
}
const tasks = Array.from(checks);
if (tasks.some(check => typeof check !== 'function')) {
throw new Error('Every check must be a function');
}
const settled = await Promise.allSettled(
tasks.map(check => Promise.resolve().then(check)));
const results = settled.map((result, index) => {
if (result.status === 'rejected') return { index, state: 'error' };
if (typeof result.value !== 'boolean') {
return { index, state: 'invalid-result' };
}
return { index, state: result.value ? 'passed' : 'failed' };
});
return { approved: results.every(r => r.state === 'passed'), results };
}
async function main() {
assert.equal([1].every(async () => false), true);
const report = await reviewChecks([
async () => true,
async () => false,
() => { throw new Error('Lookup unavailable'); },
async () => 'true'
]);
assert.equal(report.approved, false);
assert.deepEqual(report.results.map(r => r.state),
['passed', 'failed', 'error', 'invalid-result']);
assert.equal((await reviewChecks([async () => true])).approved, true);
await assert.rejects(() => reviewChecks([]));
await assert.rejects(() => reviewChecks([null]));
await assert.rejects(() => reviewChecks(new Array(1)));
let release;
const gate = new Promise(resolve => { release = resolve; });
let completed = false;
const pending = reviewChecks([() => gate]).then(r => {
completed = true;
return r;
});
await Promise.resolve();
assert.equal(completed, false);
release(true);
assert.equal((await pending).approved, true);
console.log('Asynchronous batch-review checks passed');
}
main().catch(error => { console.error(error); process.exitCode = 1; });
Save as await-checks.cjs and run node await-checks.cjs with Node.js 24. The assertions cover a false asynchronous result, a synchronous throw, a non-Boolean result, empty and sparse inputs, an approved batch and a check that has not yet completed. No external warehouse service is contacted.
Promise.allSettled() retains input order even when completion order differs. A real review screen should associate each index with a stable check name. Keep technical failure separate from a business rejection so an unavailable lookup is not reported as confirmed ineligibility.
Keep approval narrower than permission to dispatch
A drop shipping intake check and a shopify fulfillment packing check can inspect different facts. Their meaning, permitted data access and required freshness must be specified separately. Passing local checks does not reserve inventory or establish that stock is still available later.
For China fulfillment, use a bounded number of independent read-only tasks. This example provides no concurrency limit, timeout or cancellation policy; a check that never settles prevents completion. A China 3PL adapter must establish those controls before using network checks in production.
If “International Fulfillment for Folligen” is a hypothetical integration brief, it still needs those explicit contracts. I work with YX Fulfillment; its Shopify handover guide gives related operational context. These executable tests demonstrate local asynchronous control flow, not a deployed connector or live store validation.
Warehouse workstations and equipment.

Top comments (0)