MCPcopy Index your code
hub / github.com/sequelize/sequelize / enqueue

Method enqueue

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

Source from the content-addressed store, hash-verified

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

Callers 1

runMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected