Comparing version 0.10.0-next.2 to 0.10.0-next.3
@@ -205,2 +205,3 @@ "use strict"; | ||
} | ||
state.currentOp.fulfilled = true; | ||
if (typeof incomingOp.data !== "undefined") { | ||
@@ -263,6 +264,17 @@ state.currentOp.resolve(incomingOp.data); | ||
userFnPromise.then((data) => ({ type: "complete", data })), | ||
(0, promises_1.resolveAfterPending)().then(() => ({ type: "incomplete" })), | ||
(0, promises_1.resolveNextTick)().then(() => ({ type: "incomplete" })), | ||
]); | ||
if (fnRet.type === "complete") { | ||
return ["multi-complete", fnRet.data]; | ||
/** | ||
* The function has returned a value, so we should return this to | ||
* Inngest. Doing this will cause the function to be marked as | ||
* complete, so we should only do this if we're sure that all registered | ||
* ops have been resolved. | ||
*/ | ||
const allOpsFulfilled = Object.values(state.allFoundOps).every((op) => { | ||
return op.fulfilled; | ||
}); | ||
if (allOpsFulfilled) { | ||
return ["multi-complete", fnRet.data]; | ||
} | ||
} | ||
@@ -269,0 +281,0 @@ } |
@@ -6,2 +6,3 @@ import { Jsonify } from "type-fest"; | ||
fn?: (...args: any[]) => any; | ||
fulfilled: boolean; | ||
resolve: (value: any | PromiseLike<any>) => void; | ||
@@ -8,0 +9,0 @@ reject: (reason?: any) => void; |
@@ -97,3 +97,3 @@ "use strict"; | ||
state.tickOps[opId.id] = Object.assign(Object.assign(Object.assign({}, opId), (fn ? { fn: () => fn(...args) } : {})), { resolve, | ||
reject }); | ||
reject, fulfilled: false }); | ||
}); | ||
@@ -100,0 +100,0 @@ }); |
@@ -17,2 +17,6 @@ /** | ||
export declare const resolveAfterPending: () => Promise<void>; | ||
/** | ||
* Returns a Promise that resolve after the current event loop tick. | ||
*/ | ||
export declare const resolveNextTick: () => Promise<void>; | ||
//# sourceMappingURL=promises.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveAfterPending = exports.createFrozenPromise = void 0; | ||
exports.resolveNextTick = exports.resolveAfterPending = exports.createFrozenPromise = void 0; | ||
/** | ||
@@ -23,5 +23,22 @@ * A helper function to create a `Promise` that will never settle. | ||
const resolveAfterPending = () => { | ||
return new Promise((resolve) => queueMicrotask(resolve)); | ||
return new Promise((resolve) => | ||
/** | ||
* Testing found that enqueuing a single microtask would sometimes result in | ||
* the Promise being resolved before the microtask queue was drained. | ||
* | ||
* Double enqueueing does not guarantee that the queue will be empty (e.g. | ||
* if a microtask enqueues another microtask as this does), but this does | ||
* ensure that step tooling that pushes to this stack intentionally will be | ||
* correctly detected and supported. | ||
*/ | ||
queueMicrotask(() => queueMicrotask(() => resolve()))); | ||
}; | ||
exports.resolveAfterPending = resolveAfterPending; | ||
/** | ||
* Returns a Promise that resolve after the current event loop tick. | ||
*/ | ||
const resolveNextTick = () => { | ||
return new Promise((resolve) => setTimeout(resolve)); | ||
}; | ||
exports.resolveNextTick = resolveNextTick; | ||
//# sourceMappingURL=promises.js.map |
{ | ||
"name": "inngest", | ||
"version": "0.10.0-next.2", | ||
"version": "0.10.0-next.3", | ||
"description": "Official SDK for Inngest.com", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -1,2 +0,2 @@ | ||
export declare const version = "0.10.0-next.2"; | ||
export declare const version = "0.10.0-next.3"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// Generated by genversion. | ||
exports.version = "0.10.0-next.2"; | ||
exports.version = "0.10.0-next.3"; | ||
//# sourceMappingURL=version.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
498111
4743