MCPcopy
hub / github.com/sequelize/sequelize / enqueue

Method enqueue

lib/dialects/mssql/async-queue.ts:37–56  ·  view source on GitHub ↗
(asyncFunction: (...args: any[]) => Promise<unknown>)

Source from the content-addressed store, hash-verified

35 }
36
37 enqueue(asyncFunction: (...args: any[]) => Promise<unknown>) {
38 // This outer promise might seems superflous since down below we return asyncFunction().then(resolve, reject).
39 // However, this ensures that this.previous will never be a rejected promise so the queue will
40 // always keep going, while still communicating rejection from asyncFunction to the user.
41 return new Promise((resolve, reject) => {
42 this.previous = this.previous.then(() => {
43 this.rejectCurrent = reject;
44 if (this.closed) {
45 return reject(
46 new ConnectionError(
47 new AsyncQueueError(
48 'the connection was closed before this query could be executed'
49 )
50 )
51 );
52 }
53 return asyncFunction().then(resolve, reject);
54 });
55 });
56 }
57}
58
59export default AsyncQueue;

Callers 1

runMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected